Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id D6730D84656 for ; Fri, 8 Jun 2012 11:21:03 -0300 (ADT) Received: from mail.nextbus.com ([70.36.235.122] helo=toque.corp.nextbus.com) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Sd03i-0001Mf-My for pgsql-jdbc@postgresql.org; Fri, 08 Jun 2012 14:21:03 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by toque.corp.nextbus.com (Postfix) with ESMTP id D695715002A6 for ; Fri, 8 Jun 2012 07:20:49 -0700 (PDT) X-Virus-Scanned: amavisd-new at nextbus.com Received: from toque.corp.nextbus.com ([127.0.0.1]) by localhost (toque.corp.nextbus.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vULJ9uFHApoS; Fri, 8 Jun 2012 07:20:49 -0700 (PDT) Received: from papa.noky.net (cpe-74-79-19-54.twcny.res.rr.com [74.79.19.54]) by toque.corp.nextbus.com (Postfix) with ESMTPSA id C2D6515000EE; Fri, 8 Jun 2012 07:20:48 -0700 (PDT) Message-ID: <4FD20A3F.70602@nextbus.com> Date: Fri, 08 Jun 2012 10:20:47 -0400 From: Mike Charnoky User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Hung JDBC connections Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/30 X-Sequence-Number: 23024 Hi, Yesterday we experienced a problem whereby hundreds of JDBC client connections remained in a hung state, despite the fact that the PostgreSQL server was actually rebooted. This is disconcerting because our client applications have a db failover facility, but that feature won't work unless existing JDBC connections (most of which are pooled) fail in the first place. We had to instead manually restart all client applications to eliminate all the hung connections. Here are the details: * server: PostgreSQL v8.3 on CentOS 5.4 * clients: JDBC v9.0-802.jdbc4, Java 1.6.0_30, on various CentOS 5.x releases The strange thing is that on the client side, according to "netstat" the TCP connections between the JDBC clients and PostgreSQL were still in the ESTABLISHED state (even though the server was rebooted). A thread dump of the a typical hung client (one performing DB updates) looked like this, it was stuck in a socket read. I was further surprised that some test clients (which I did not restart yesterday) are STILL in this hung state this morning, 18 hours after the incident! "DBThrottle-" prio=10 tid=0xad1ff400 nid=0x24b8 runnable [0xad2ad000] java.lang.Thread.State: RUNNABLE at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) at org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:145) at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:114) at org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:73) at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:274) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1660) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407) - locked <0xb243db20> (a org.postgresql.core.v3.QueryExecutorImpl) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2725) at xxx.xxxxxxx.util.DBThrottle.sqlLoop(DBThrottle.java:401) at xxx.xxxxxxx.util.DBThrottle.access$000(DBThrottle.java:59) at xxx.xxxxxxx.util.DBThrottle$1.run(DBThrottle.java:199) Is there a way this hang can be addressed by the JDBC driver? Again, this is very disconcerting that the clients did not detect the server failure. Does the connection use any sort of timeout mechanism? Thank you for your help. Mike