Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 98ACD5D026C for ; Fri, 29 Jun 2012 00:15:26 -0300 (ADT) Received: from mail-ob0-f174.google.com ([209.85.214.174]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SkRg4-0005mg-TR for pgsql-jdbc@postgresql.org; Fri, 29 Jun 2012 03:15:25 +0000 Received: by obbuo13 with SMTP id uo13so3948421obb.19 for ; Thu, 28 Jun 2012 20:15:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:x-gm-message-state; bh=4zm+DOjGDK6qrfpEgP2L19Rb8UdP2h25HpTVm16YeYQ=; b=mIUv+xCJhth/UMrEtE/KO6F99PmKt5jlyJZ8Q0NiOC2usStn19DnxtE8ObL72eYBmq p4IHVeRkPGyWhJwBby2eyaXmlzBOch+IkBUixmsbG58/CKPc6oArGRzm8bYdpE1as2Y6 JACdcSzh+EipVdyFMIS5NHadhpmQBN18qm70FD8yFvSLIAvPyxOhX2IktjTM2u1jNuOZ tO9/KsMbD66GTq99Dv56N7fBhLbNpSPwPZ+WKAwXIxeLrvdYuEQmZ/bWvCe8WHf5gLFq MIR+bz5q88QQjmQbPwCHBFKJypUlBqwzCNJvwVMaiRk1TYaH8CgRpoyn8T3KEOA59oNs id8w== Received: by 10.50.46.232 with SMTP id y8mr310278igm.57.1340939711159; Thu, 28 Jun 2012 20:15:11 -0700 (PDT) Received: from ayaki.localdomain (124-169-169-118.dyn.iinet.net.au. [124.169.169.118]) by mx.google.com with ESMTPS id if4sm967145igc.10.2012.06.28.20.15.08 (version=SSLv3 cipher=OTHER); Thu, 28 Jun 2012 20:15:10 -0700 (PDT) Message-ID: <4FED1DB9.50602@ringerc.id.au> Date: Fri, 29 Jun 2012 11:15:05 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: Kiran Kulkarni CC: Dave Cramer , "pgsql-jdbc@postgresql.org" Subject: Re: org.postgresql.util.PSQLException: An I/O error occured while sending to the backend References: <1340835352.64379.YahooMailNeo@web161405.mail.bf1.yahoo.com> <1340900124.55466.YahooMailNeo@web161403.mail.bf1.yahoo.com> In-Reply-To: <1340900124.55466.YahooMailNeo@web161403.mail.bf1.yahoo.com> Content-Type: multipart/alternative; boundary="------------000900050303070809000909" X-Gm-Message-State: ALoCoQmawnYYNnsdi07ihZTQdt3aCH7cX92xVddPinzR0rkuLnwSu3Ytm2FgBQNkUKD/ZP6yoa2X X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/103 X-Sequence-Number: 23097 This is a multi-part message in MIME format. --------------000900050303070809000909 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 06/29/2012 12:15 AM, Kiran Kulkarni wrote: > Hello David, > We are using postgres 9.0 and JDBC driver is postgresql-8.4-701.jdbc3.jar. Try to use a JDBC driver at least as new, if not newer than, the server. The client(s) should always be the same release as or newer than the server. The same goes for psql, libpq, etc. > Our app server & DB, both are running on Linux and there is a firewall > between app server and DB. Tharrr's yer problem. Does the firewall do NAT or stateful connection tracking? If so, you /must/ use keepalives to avoid connection drops if your connections are idle for long. If you don't know, then your firewall probably does do connection tracking and thus you must use keepalives. If you're on a Java EE application server you can get the server to send a dummy connection check statement like "SELECT 1" every now and then instead of using OS level keepalives. I'd prefer an OS level keepalive, though, as unlike connection check statements they don't fill the logs with noise. > Can upgrading the driver to higher version fix this problem? Probably not if there's a firewall involved. > > I have seen similar posts on the web. Most tell either to reconnect or > to try TCP Keep alive. > For my case, hibernate is managing my connections and I would expect > hibernate to deal with such scenarios. It doesn't and it can't. If you configure your connection pool to verify/check connections you'll reduce the frequency with which this happens, but not eliminate it. Your app MUST handle connection and transaction failures if it wants to be robust. It's a pain, but necessary. > But since it is not dealing with such issues I would be more > comfortable configuring tcp keep alive rather than meddling hibernate > managed connections. > > Do you know any configuration in hibernate which takes care of such > issues? Or else pls give me the steps to configure tcp keep alive. > Hibernate cannot do everything for you. If the database connection is lost partway through a transaction then YOU must reissue the work. It'd be nice if Hibernate could handle the reconnect-and-retry logic for you, but at the moment it can't - and in fact it even mangles your entity objects when a transaction fails. I wrote a post on another thread about this a day or two ago, but accidentally forgot to CC the list. I've re-posted it with subject "Re: [JDBC] org.postgresql.util.PSQLException: An I/O error occured while sending to the backend" and it should appear in the archives as http://archives.postgresql.org/message-id/4FED1C55.4050507@ringerc.id.au when the archives are next updated. -- Craig Ringer --------------000900050303070809000909 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
On 06/29/2012 12:15 AM, Kiran Kulkarni wrote:
Hello David,
We are using postgres 9.0 and JDBC driver is postgresql-8.4-701.jdbc3.jar.

Try to use a JDBC driver at least as new, if not newer than, the server. The client(s) should always be the same release as or newer than the server. The same goes for psql, libpq, etc.

Our app server & DB, both are running on Linux and there is a firewall between app server and DB.
Tharrr's yer problem.

Does the firewall do NAT or stateful connection tracking? If so, you must use keepalives to avoid connection drops if your connections are idle for long. If you don't know, then your firewall probably does do connection tracking and thus you must use keepalives.

If you're on a Java EE application server you can get the server to send a dummy connection check statement like "SELECT 1" every now and then instead of using OS level keepalives. I'd prefer an OS level keepalive, though, as unlike connection check statements they don't fill the logs with noise.

Can upgrading the driver to higher version fix this problem?

Probably not if there's a firewall involved.

I have seen similar posts on the web. Most tell either to reconnect or to try TCP Keep alive.
For my case, hibernate is managing my connections and I would expect hibernate to deal with such scenarios.
It doesn't and it can't.

If you configure your connection pool to verify/check connections you'll reduce the frequency with which this happens, but not eliminate it. Your app MUST handle connection and transaction failures if it wants to be robust. It's a pain, but necessary.

But since it is not dealing with such issues I would be more comfortable configuring tcp keep alive rather than meddling hibernate managed connections.

Do you know any configuration in hibernate which takes care of such issues? Or else pls give me the steps to configure tcp keep alive.

Hibernate cannot do everything for you. If the database connection is lost partway through a transaction then YOU must reissue the work. It'd be nice if Hibernate could handle the reconnect-and-retry logic for you, but at the moment it can't - and in fact it even mangles your entity objects when a transaction fails.

I wrote a post on another thread about this a day or two ago, but accidentally forgot to CC the list. I've re-posted it with subject "Re: [JDBC] org.postgresql.util.PSQLException: An I/O error occured while sending to the backend" and it should appear in the archives as http://archives.postgresql.org/message-id/4FED1C55.4050507@ringerc.id.au when the archives are next updated.

--
Craig Ringer
--------------000900050303070809000909--