Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r8NBH-009XRA-Ad for pgsql-jdbc@arkaria.postgresql.org; Wed, 29 Nov 2023 16:12:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r8NBG-00Be4g-0d for pgsql-jdbc@arkaria.postgresql.org; Wed, 29 Nov 2023 16:12:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r8NBF-00Be4Y-OJ for pgsql-jdbc@lists.postgresql.org; Wed, 29 Nov 2023 16:12:53 +0000 Received: from pgintl.fastcrypt.com ([149.56.129.164]) by magus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r8NB4-009CAG-NO for pgsql-jdbc@lists.postgresql.org; Wed, 29 Nov 2023 16:12:52 +0000 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by pgintl.fastcrypt.com (Postfix) with ESMTPSA id B5829202BC for ; Wed, 29 Nov 2023 11:12:39 -0500 (EST) Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-54af1daf6a9so2096272a12.1 for ; Wed, 29 Nov 2023 08:12:39 -0800 (PST) X-Gm-Message-State: AOJu0YxUCJjUw0RLwa4eoIghi5PDZdu85GOf2vArsmCTUaWcY9X9cLC/ DyirVHcZ9HxKBgFwc5ESuKXLxCQhyRBovwhw7XA= X-Google-Smtp-Source: AGHT+IGmfYrCWO5uB73w0GyyPq3nqtflUJ5HKGlZ5WyoYeAOAFYDe4U2PGlZQYJBWyBSbzKTM5Sl3Tw5XhkUEit/aUA= X-Received: by 2002:a05:6402:358d:b0:54b:7b24:810e with SMTP id y13-20020a056402358d00b0054b7b24810emr9392622edc.14.1701274358344; Wed, 29 Nov 2023 08:12:38 -0800 (PST) MIME-Version: 1.0 References: <2c2e0f5d-4fe2-472f-a213-5cf58ec993c5.ref@yahoo.com> <2c2e0f5d-4fe2-472f-a213-5cf58ec993c5@yahoo.com> In-Reply-To: From: Dave Cramer Date: Wed, 29 Nov 2023 11:12:21 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Driver hangs in connect->MakeSSL.convert->SSLSocketImpl.startHandshake To: Martin Lichtin Cc: pgsql-jdbc@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000cb71e8060b4ccd51" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000cb71e8060b4ccd51 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 29 Nov 2023 at 11:06, Martin Lichtin wrote: > > On 28/11/2023 21:28, Dave Cramer wrote: > > On Tue, 28 Nov 2023 at 09:07, Dave Cramer > wrote: > >> Hi Martin, >> >> Thanks for the report. I'll have a look. >> Dave Cramer >> >> On Tue, 28 Nov 2023 at 08:27, Martin Lichtin wrote: >> >>> Hi >>> >>> I'm seeing this thread hanging in the "getConnection" method, with no >>> timeout in sight. >>> However, the PGXADataSource is configured with a "connectTimeout" of 10 >>> seconds. >>> >>> java.lang.Thread.State: RUNNABLE >>> at java.net.SocketInputStream.socketRead0(Native Method) >>> at java.net.SocketInputStream.socketRead(SocketInputStream.java:116= ) >>> at java.net.SocketInputStream.read(SocketInputStream.java:171) >>> at java.net.SocketInputStream.read(SocketInputStream.java:141) >>> at >>> sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:46= 4) >>> at >>> sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:= 165) >>> at sun.security.ssl.SSLTransport.decode(SSLTransport.java:109) >>> at sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1392) >>> at >>> sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1= 300) >>> at >>> sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:435) >>> at org.postgresql.ssl.MakeSSL.convert(MakeSSL.java:41) >>> ... >>> at java.sql.DriverManager.getConnection(DriverManager.java:247) >>> at >>> org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.ja= va:103) >>> at >>> org.postgresql.xa.PGXADataSource.getXAConnection(PGXADataSource.java:49= ) >>> at >>> org.postgresql.xa.PGXADataSource.getXAConnection(PGXADataSource.java:35= ) >>> >>> Any reason this timeout is not being applied here? >>> >>> The version in use here is 42.3.6 >>> >> > This Make sure to pass any network timeouts to the new SSL connection. by > davecramer =C2=B7 Pull Request #3040 =C2=B7 pgjdbc/pgjdbc (github.com) > should fix the problem, can > you check ? > > Thanks! I'll try. Was hoping for a SNAPSHOT version with this change in, > but looks like these are no longer produced(?), although mentioned here > https://jdbc.postgresql.org/download/ Anyways, it will be quite hard to > reproduce this socket-read hang situation, so not sure I'll be able to te= st > the change :) > In order to create a snapshot version I would need to merge the change in. > Some more observations (obv from a newcomer to this space..): > > As mentioned I'm setting "connectTimeout". Is this value somehow tricklin= g > down, and ending up at what's called "networkTimeout" in the code? > I'm asking as networkTimeout is not a connection parameter.. > https://jdbc.postgresql.org/documentation/use/ > > Also confusing to me is the existing parameter "sslResponseTimeout", this > defaults to 5 seconds, and is already documented as 'the maximum time to > wait for a response after requesting an SSL encrypted connection from the > server'. Shouldn't this value be used in above case. > Fair question > Lastly, seeing "socketTimeout", however I would not want to set this one, > as it could interfere with long-running queries, and to me, should not be > used during connection setup. > Should probably reset it after connecting. Thanks, Dave > - Martin > --000000000000cb71e8060b4ccd51 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Wed, 29 Nov 2023 at 11:06, Martin = Lichtin <lichtin@yahoo.com> = wrote:
=20 =20 =20


On 28/11/2023 21:28, Dave Cramer wrote:
=20
On Tue, 28 Nov 2023 at 09:07, Dave Cramer &l= t;davecramer@postgres.rocks> wrote:
Hi=C2=A0Martin,

Thanks for the report. I'll have a look.=C2=A0
Dave Cramer

On Tue, 28 Nov 2023 a= t 08:27, Martin Lichtin <lichtin@yahoo.com> wrote:

Hi

I'm seeing this thread hanging in the "getConnection" method, wi= th no timeout in sight.
However, the PGXADataSource is configu= red with a "connectTimeout" of 10 seconds.

=C2=A0=C2=A0 java.lang.Thread= .State: RUNNABLE
=C2=A0=C2=A0 =C2=A0at java.net.SocketInputStream.socketRead0(Native Method)
=C2=A0=C2=A0 =C2=A0at java.net.SocketInputStream.socketRead(SocketInputSt= ream.java:116)
=C2=A0=C2=A0 =C2=A0at java.net.SocketInputStream.read(SocketInputStream.j= ava:171)
=C2=A0=C2=A0 =C2=A0at java.net.SocketInputStream.read(SocketInputStream.j= ava:141)
=C2=A0=C2=A0 =C2=A0at sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:464) =C2=A0=C2=A0 =C2=A0at sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:165)=
=C2=A0=C2=A0 =C2=A0at sun.security.ssl.SSLTransport.decode(SSLTransport.j= ava:109)
=C2=A0=C2=A0 =C2=A0at sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl= .java:1392)
=C2=A0=C2=A0 =C2=A0at sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1300)=
=C2=A0=C2=A0 =C2=A0at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSo= cketImpl.java:435)
=C2=A0=C2=A0 =C2=A0at org.postgresql.ssl.MakeSSL.convert(MakeSSL.java:41)=
...
=C2=A0=C2=A0 =C2=A0at java.sql.DriverManager.getConnection(DriverManager.= java:247)
=C2=A0=C2=A0 =C2=A0at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:1= 03)
=C2=A0=C2=A0 =C2=A0at org.postgresql.xa.PGXADataSource.getXAConnection(PG= XADataSource.java:49)
=C2=A0=C2=A0 =C2=A0at org.postgresql.xa.PGXADataSource.getXAConnection(PG= XADataSource.java:35)

Any reason this timeout is not being applied here?

The version in use here is 42.3.6


Thanks! I'll try. Was hoping for a SNAPSHOT version with this change in, but looks like these are no longer produced(?), although mentioned here https://jdbc.postgresql.org/download/=C2=A0 Anyways, it will be quite hard to reproduce this socket-read hang situation, so not sure I'll be able to test the change :)

=

In order to create a snapshot versio= n I would need to merge the change in.
=C2=A0

Some more observations (obv from a newcomer to this space..):

As mentioned I'm setting "connectTimeout". Is this val= ue somehow trickling down, and ending up at what's called "networkTimeo= ut" in the code?
I'm asking as networkTimeout is not a connection parameter.. https://jdbc.postgresql.org/documentation/use/

Also confusing to me is the existing parameter "sslResponseTimeout", this defaults to 5 seconds, and is al= ready documented as 'the maximum time to wait for a response after requesting an SSL encrypted connection from the server'. Shouldn&= #39;t this value be used in above case.

Fair que= stion=C2=A0

Lastly, seeing "socketTimeout", however I would not want t= o set this one, as it could interfere with long-running queries, and to me, should not be used during connection setup.


Should probably reset it after connecting.

Thanks,
Dave=C2=A0

- Martin

--000000000000cb71e8060b4ccd51--