pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedConnection state after network failure?
4+ messages / 3 participants
[nested] [flat]
* Connection state after network failure?
@ 2007-02-09 19:10 Kevin Birkett <KBirkett@icudata.com>
0 siblings, 2 replies; 4+ messages in thread
From: Kevin Birkett @ 2007-02-09 19:10 UTC (permalink / raw)
To: pgsql-jdbc
Hello,
I'm having a problem with our software which uses Postgres 7.2.3 and the JDBC driver associated with it. In our code we only create one connection to the database, and then use that connection as needed for our DB interaction. The problem comes in when I simulate a network failure (yank the cat5) after the app has started up and connected to the remote database. I've tried an idea I found by searching the archives of this mailing list, but I haven't been able to get it to work.
My current technique is:
try {
con.createStatement().execute("Select 1");
} catch (Exception e) {
......
......
}
To me, if the connection loses its network connectivity, an exception should be thrown here, and then I can handle it. However, what actually happens is the system locks up on the call to execute and it never throws and exception or a returns value (since the network is unavailable). Am I missing something easy here? All I want to do is to check whether or not the connection is valid and available.
Thanks for any help you can give.
Kevin
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Connection state after network failure?
@ 2007-02-09 22:32 Scott Marlowe <smarlowe@g2switchworks.com>
parent: Kevin Birkett <KBirkett@icudata.com>
1 sibling, 0 replies; 4+ messages in thread
From: Scott Marlowe @ 2007-02-09 22:32 UTC (permalink / raw)
To: Kevin Birkett <KBirkett@icudata.com>; +Cc: pgsql-jdbc
On Fri, 2007-02-09 at 13:10, Kevin Birkett wrote:
> Hello,
>
> I'm having a problem with our software which uses Postgres 7.2.3 and
> the JDBC driver associated with it. In our code we only create one
> connection to the database, and then use that connection as needed for
> our DB interaction. The problem comes in when I simulate a network
> failure (yank the cat5) after the app has started up and connected to
> the remote database. I've tried an idea I found by searching the
> archives of this mailing list, but I haven't been able to get it to
> work.
I can only assume you're using the same jdbc driver version as you are
postgresql.
7.2.3 is quite old. We had some minor issues with the early 7.4 jdbc
drivers, and there have been man releases since then.
pgsql 7.2 has known unfixable bugs, and given enough time, it WILL eat
your data.
Please investigate updating to the latest or nearly so version of
postgresql and see if that helps. I'd recommend at least 8.1.x, but the
latest 8.2.3 seems pretty stable and I'm testing it already for internal
use.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Connection state after network failure?
@ 2007-02-14 06:11 Kris Jurka <books@ejurka.com>
parent: Kevin Birkett <KBirkett@icudata.com>
1 sibling, 1 reply; 4+ messages in thread
From: Kris Jurka @ 2007-02-14 06:11 UTC (permalink / raw)
To: Kevin Birkett <KBirkett@icudata.com>; +Cc: pgsql-jdbc
On Fri, 9 Feb 2007, Kevin Birkett wrote:
> I'm having a problem with our software which uses Postgres 7.2.3 and the
> JDBC driver associated with it. In our code we only create one
> connection to the database, and then use that connection as needed for
> our DB interaction. The problem comes in when I simulate a network
> failure (yank the cat5) after the app has started up and connected to
> the remote database. I've tried an idea I found by searching the
> archives of this mailing list, but I haven't been able to get it to
> work.
>
> To me, if the connection loses its network connectivity, an exception
> should be thrown here, and then I can handle it. However, what actually
> happens is the system locks up on the call to execute and it never
> throws and exception or a returns value (since the network is
> unavailable). Am I missing something easy here? All I want to do is to
> check whether or not the connection is valid and available.
>
TCP doesn't detect network failures immediately, hoping the network will
be restored. If you wait long enough (on the order of an hour) you will
get an Exception. You can adjust these settings globally via your OS
or using a more recent postgresql version with tcp_keepalives_* here:
http://www.postgresql.org/docs/8.2/static/runtime-config-connection.html
Also get off the 7.2 release before it eats your data.
Kris Jurka
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Connection state after network failure?
@ 2007-02-14 14:50 Kevin Birkett <KBirkett@icudata.com>
parent: Kris Jurka <books@ejurka.com>
0 siblings, 0 replies; 4+ messages in thread
From: Kevin Birkett @ 2007-02-14 14:50 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc
Thanks for the advice guys. We have a legacy app that was built on 7.2, and we are working to get away from it. We had a few issues with some functions not being available in the newer versions, and I think we have them almost worked out. I will try to get a newer version of the db installed and test out some of the suggestions mentioned.
Thanks again for the help.
________________________________
From: Kris Jurka [mailto:books@ejurka.com]
Sent: Wed 2/14/2007 1:11 AM
To: Kevin Birkett
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] Connection state after network failure?
On Fri, 9 Feb 2007, Kevin Birkett wrote:
> I'm having a problem with our software which uses Postgres 7.2.3 and the
> JDBC driver associated with it. In our code we only create one
> connection to the database, and then use that connection as needed for
> our DB interaction. The problem comes in when I simulate a network
> failure (yank the cat5) after the app has started up and connected to
> the remote database. I've tried an idea I found by searching the
> archives of this mailing list, but I haven't been able to get it to
> work.
>
> To me, if the connection loses its network connectivity, an exception
> should be thrown here, and then I can handle it. However, what actually
> happens is the system locks up on the call to execute and it never
> throws and exception or a returns value (since the network is
> unavailable). Am I missing something easy here? All I want to do is to
> check whether or not the connection is valid and available.
>
TCP doesn't detect network failures immediately, hoping the network will
be restored. If you wait long enough (on the order of an hour) you will
get an Exception. You can adjust these settings globally via your OS
or using a more recent postgresql version with tcp_keepalives_* here:
http://www.postgresql.org/docs/8.2/static/runtime-config-connection.html
Also get off the 7.2 release before it eats your data.
Kris Jurka
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2007-02-14 14:50 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-02-09 19:10 Connection state after network failure? Kevin Birkett <KBirkett@icudata.com>
2007-02-09 22:32 ` Scott Marlowe <smarlowe@g2switchworks.com>
2007-02-14 06:11 ` Kris Jurka <books@ejurka.com>
2007-02-14 14:50 ` Kevin Birkett <KBirkett@icudata.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