Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZmTZH-0007BZ-PU for pgsql-jdbc@arkaria.postgresql.org; Wed, 14 Oct 2015 21:26:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZmTZH-0007V8-31 for pgsql-jdbc@arkaria.postgresql.org; Wed, 14 Oct 2015 21:26:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZmTZF-0007Uv-Io for pgsql-jdbc@postgresql.org; Wed, 14 Oct 2015 21:26:37 +0000 Received: from mbob.nabble.com ([162.253.133.15]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZmTZB-0005J8-MI for pgsql-jdbc@postgresql.org; Wed, 14 Oct 2015 21:26:36 +0000 Received: from msam.nabble.com (unknown [162.253.133.85]) by mbob.nabble.com (Postfix) with ESMTP id 05E4E17A9A25 for ; Wed, 14 Oct 2015 14:18:19 -0700 (PDT) Date: Wed, 14 Oct 2015 14:26:31 -0700 (MST) From: lfrittelli To: pgsql-jdbc@postgresql.org Message-ID: <1444857991068-5870008.post@n5.nabble.com> In-Reply-To: <561A3FC8.6080305@kiwi-fraser.net> References: <0c59e097a3ec4139b049b89627fb149f@exchange.sh-solutions.de> <543c7dab3e334742b02d18dcf7b2c49a@exchange.sh-solutions.de> <561A3FC8.6080305@kiwi-fraser.net> Subject: Re: Connection terminated by the server causes deadlock in jdbc client side connection MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -0.3 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Donald, These are good points all. Let me provide more context for my scenario on each item > First I'd like to say that even though we are dealing with TCP one must > treat it almost like UDP. TCP > packets can be consumed by firewalls and proxy servers with no response > given to the sender. So with > that in mind to create a robust fault tolerant driver, timeout on all TCP > communications is a must. True in the general case, but I don't think it would have affected the specific scenario under issue. For context on the scenario, note that there was no firewall or proxy. We were using local connections (jdbc:postgresql://localhost...) > 1) So in the first case where an IOException is thrown, the original code > that is closing the connection > via "close" cannot have a timeout feature enabled and that will still > exist in the code with the potential > to fail... As the 'graceful' close() method will write on the socket, would it be possible to put a timeout on write? I am no expert but have not been able to find out how. > 2) When an IOException is thrown as the origin of an exception this should > not be lost and should > always be attached to the final exception. I don't see this cascaded in > the updated driver using the > "abort" code... At least in some of the cases it appears that the original IO error is consumed and converted to an error SQL state, and not re-thrown. In other cases there is actually a message from the server advising of the termination and this is somehow interpreted by the client, thus no IO exception in those cases. Here is a more detailed log capture (including some Hibernate entries) - again, this is after the fix: (SqlExceptionHelper.java:145) - SQL Error: 0, SQLState: 40001 (SqlExceptionHelper.java:147) - FATAL: terminating connection due to conflict with recovery Detail: User query might have needed to see row versions that must be removed. Hint: In a moment you should be able to reconnect to the database and repeat your command. org.hibernate.exception.LockAcquisitionException: could not extract ResultSet at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:140) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:61) at org.hibernate.loader.Loader.getResultSet(Loader.java:2040) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1837) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1816) at org.hibernate.loader.Loader.doQuery(Loader.java:900) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:342) at org.hibernate.loader.Loader.doList(Loader.java:2526) at org.hibernate.loader.Loader.doList(Loader.java:2512) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2342) at org.hibernate.loader.Loader.list(Loader.java:2337) at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:124) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1662) at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:374) ... Caused by: org.postgresql.util.PSQLException: FATAL: terminating connection due to conflict with recovery Detail: User query might have needed to see row versions that must be removed. Hint: In a moment you should be able to reconnect to the database and repeat your command. at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2198) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1927) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:562) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:420) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:305) ... 46 more Let me know if there is any additional detail that I could provide. Regards, Leonardo -- View this message in context: http://postgresql.nabble.com/Connection-terminated-by-the-server-causes-deadlock-in-jdbc-client-side-connection-tp5869131p5870008.html Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com. -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc