From: Craig Ringer <craig@postnewspapers.com.au>
To: Rod <cckramer@gmail.com>
Cc: pgsql-jdbc <pgsql-jdbc@postgresql.org>
Subject: Re: After server restart I get - An I/O error occured while sending to the backend.
Date: Tue, 18 May 2010 19:42:09 +0800
Message-ID: <4BF27D11.8020001@postnewspapers.com.au> (raw)
In-Reply-To: <AANLkTilHOdiZ0kiIkPg51KGnz9BTgKK4PWQ-3QwzKkrq@mail.gmail.com>
References: <AANLkTilHOdiZ0kiIkPg51KGnz9BTgKK4PWQ-3QwzKkrq@mail.gmail.com>
On 18/05/2010 6:41 PM, Rod wrote:
> Hi,
>
> I have simple JDBC client app running on Jetty.
> Using 8.3 JDBC3 driver and PostgreSQL8.3 server running on localhost.
>
> Any time I restart the PostgresQL server I get SQL error:
> An I/O error occured while sending to the backend.
>
> It appears that my application's connection to the server is not
> re-established by some reason?
Pooled connections usually don't get cleaned up until they're discovered
to be dead. That happens when you try to use them and they break.
Just be prepared for this to happen. If you get a bad connection, grab a
new one and re-try your work.
Yes, you can "test" the connection first ... but something might go
wrong with it between testing it and starting to use it. You need to be
prepared to handle failure at any point and re-try your work. Make sure
to keep your work separated into clear units of work (wrapped as
transactions) so you have a clear idea of what you're up to.
>
> I am no expert in JDBC.
> First I was using plan JDBC. I thought that using DB connection pool
> will automagically reconnect and solve this problem.
> Switching to Apache commons DBCP did not change anything.
>
> What am I supposed to do to make it survive PostgreSQL server restart?
It can't, just as it can't survive connection loss for other reasons.
Your code must be prepared to deal with that.
--
Craig Ringer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: craig@postnewspapers.com.au, cckramer@gmail.com
Subject: Re: After server restart I get - An I/O error occured while sending to the backend.
In-Reply-To: <4BF27D11.8020001@postnewspapers.com.au>
References: <AANLkTilHOdiZ0kiIkPg51KGnz9BTgKK4PWQ-3QwzKkrq@mail.gmail.com> <4BF27D11.8020001@postnewspapers.com.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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