pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedJDBC client hangs on socketRead()
3+ messages / 2 participants
[nested] [flat]
* JDBC client hangs on socketRead()
@ 2016-05-24 12:33 Michał Niklas <michal.niklas@heuthes.pl>
0 siblings, 1 reply; 3+ messages in thread
From: Michał Niklas @ 2016-05-24 12:33 UTC (permalink / raw)
To: pgsql-jdbc
I have multithread Java service using JDBC connections from pool and
sometimes it hangs some threads at socketRead() while PostgreSQL shows
that all connections are in idle state.
My internal logging shows that the last statement I called in those
threads was:
ResultSet rs = stmt.executeQuery();
From my client jstack output looks like:
"/client1_160524084431" #65702 daemon prio=5 os_prio=0
tid=0x00007fc2fc016800 nid=0x10c9 runnable [0x00007fc297ffd000]
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:170)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at
org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:143)
at
org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:112)
at
org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:70)
at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:283)
at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1799)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200)
- locked <0x00000005dea42868> (a org.postgresql.core.v3.QueryExecutorImpl)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424)
at
org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:161)
at
org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:114)
...
"/client2_160524084407" #65374 daemon prio=5 os_prio=0
tid=0x00007fc2fc0e8800 nid=0xf81 runnable [0x00007fc2adbfc000]
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:170)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at
org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:143)
at
org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:112)
at
org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:70)
at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:283)
at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1799)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200)
- locked <0x00000005df264838> (a org.postgresql.core.v3.QueryExecutorImpl)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424)
at
org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:161)
at
org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:114)
...
(more similar threads, all trying to socketRead())
...
At server side those connections show idle state:
polkitd 736 0.0 0.0 8512128 30464 ? Ss 07:59 0:00
postgres: postgres client1 192.168.1.124(47685) idle
polkitd 857 0.0 0.0 8509548 20824 ? Ss 08:02 0:00
postgres: postgres client2 192.168.1.124(47809) idle
...
(more similar connections)
My environment:
Client:
OS: Linux
JVM: 1.8.0_92 (Oracle Corporation)
JDBC: postgresql-9.4.1208.jar, Java JDBC 4.2 (JRE 8+) driver for
PostgreSQL database
Server:
Version: PostgreSQL 9.5.3 on x86_64-pc-linux-gnu, compiled by gcc
(Debian 4.9.2-10) 4.9.2, 64-bit
OS: Linux
Both service and database server runs on separate docker environments.
My question is:
Why I observe such hanging threads?
--
Regards,
Michał Niklas
Attachments:
signature.asc (application/pgp-signature, 472B) download
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: JDBC client hangs on socketRead()
@ 2016-05-24 12:47 Dave Cramer <pg@fastcrypt.com>
parent: Michał Niklas <michal.niklas@heuthes.pl>
0 siblings, 1 reply; 3+ messages in thread
From: Dave Cramer @ 2016-05-24 12:47 UTC (permalink / raw)
To: Michał Niklas <michal.niklas@heuthes.pl>; +Cc: pgsql-jdbc
My guess is that somehow two threads are using the same connection. Is that
probable?
Dave Cramer
davec@postgresintl.com
www.postgresintl.com
On 24 May 2016 at 08:33, Michał Niklas <michal.niklas@heuthes.pl> wrote:
> I have multithread Java service using JDBC connections from pool and
> sometimes it hangs some threads at socketRead() while PostgreSQL shows
> that all connections are in idle state.
>
> My internal logging shows that the last statement I called in those
> threads was:
>
> ResultSet rs = stmt.executeQuery();
>
> From my client jstack output looks like:
>
> "/client1_160524084431" #65702 daemon prio=5 os_prio=0
> tid=0x00007fc2fc016800 nid=0x10c9 runnable [0x00007fc297ffd000]
> 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:170)
> at java.net.SocketInputStream.read(SocketInputStream.java:141)
> at
>
> org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:143)
> at
>
> org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:112)
> at
>
> org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:70)
> at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:283)
> at
>
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1799)
> at
>
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200)
> - locked <0x00000005dea42868> (a
> org.postgresql.core.v3.QueryExecutorImpl)
> at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424)
> at
>
> org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:161)
> at
>
> org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:114)
> ...
>
> "/client2_160524084407" #65374 daemon prio=5 os_prio=0
> tid=0x00007fc2fc0e8800 nid=0xf81 runnable [0x00007fc2adbfc000]
> 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:170)
> at java.net.SocketInputStream.read(SocketInputStream.java:141)
> at
>
> org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:143)
> at
>
> org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:112)
> at
>
> org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:70)
> at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:283)
> at
>
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1799)
> at
>
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200)
> - locked <0x00000005df264838> (a
> org.postgresql.core.v3.QueryExecutorImpl)
> at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424)
> at
>
> org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:161)
> at
>
> org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:114)
> ...
>
> (more similar threads, all trying to socketRead())
> ...
>
> At server side those connections show idle state:
>
> polkitd 736 0.0 0.0 8512128 30464 ? Ss 07:59 0:00
> postgres: postgres client1 192.168.1.124(47685) idle
> polkitd 857 0.0 0.0 8509548 20824 ? Ss 08:02 0:00
> postgres: postgres client2 192.168.1.124(47809) idle
> ...
> (more similar connections)
>
> My environment:
>
> Client:
> OS: Linux
> JVM: 1.8.0_92 (Oracle Corporation)
> JDBC: postgresql-9.4.1208.jar, Java JDBC 4.2 (JRE 8+) driver for
> PostgreSQL database
>
> Server:
> Version: PostgreSQL 9.5.3 on x86_64-pc-linux-gnu, compiled by gcc
> (Debian 4.9.2-10) 4.9.2, 64-bit
> OS: Linux
>
> Both service and database server runs on separate docker environments.
>
>
> My question is:
> Why I observe such hanging threads?
>
> --
> Regards,
> Michał Niklas
>
>
>
>
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: JDBC client hangs on socketRead()
@ 2016-05-24 13:15 Dave Cramer <pg@fastcrypt.com>
parent: Dave Cramer <pg@fastcrypt.com>
0 siblings, 0 replies; 3+ messages in thread
From: Dave Cramer @ 2016-05-24 13:15 UTC (permalink / raw)
To: Michał Niklas <michal.niklas@heuthes.pl>; pgjdbc/pgjdbc <pgjdbc@noreply.github.com>; pgsql-jdbc
+list(s)
My guess then would be docker networking issues. This is not a report we
have seen before.
Dave Cramer
davec@postgresintl.com
www.postgresintl.com
On 24 May 2016 at 08:56, Michał Niklas <michal.niklas@heuthes.pl> wrote:
> W dniu 24.05.2016 o 14:47, Dave Cramer pisze:
> > My guess is that somehow two threads are using the same connection. Is
> > that probable?
>
> No. Those connections are to separate databases,
> sometimes on different machines.
>
> --
> Regards,
> Michał Niklas
>
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2016-05-24 13:15 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-05-24 12:33 JDBC client hangs on socketRead() Michał Niklas <michal.niklas@heuthes.pl>
2016-05-24 12:47 ` Dave Cramer <pg@fastcrypt.com>
2016-05-24 13:15 ` Dave Cramer <pg@fastcrypt.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox