No timeout to establish Connection?

From: "Roman Fail" <rfail(at)posportal(dot)com>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: No timeout to establish Connection?
Date: 2003-07-03 18:40:19
Message-ID: 9B1C77393DED0D4B9DAA1AA1742942DA3BCC69@pos_pdc.posportal.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Please forgive my ignorance if this has already been covered, but the list archives are down. (If anyone is interested, the archive page returns: DB err: FATAL: No pg_hba.conf entry for host 64.117.224.193, user pgsql, database 186_archives).

Anyway, on to my problem. I am using pg73jdbc3.jar (dated 11/30/2002) on a production Tomcat 4.1.24 Linux server. The PostgreSQL server is a separate machine running 7.3.1, also on Linux. (Of course I plan on upgrading to 7.3.3 and the latest JDBC driver ASAP).

The symptom:
Tomcat would almost completely crash whenever the Postgres database was accessed. While I did not have time to fully quantify the exact Java problem, it appears that the opening of a new Connection set caused the crash. (Note, JVM did not crash, just all the webapps). My guess is that the the DriverManager.getConnection(...) statement just runs and runs but never completes. No timeout, so the whole JVM is waiting on it to finish.

My workaround is to create a separate thread to get the Connection, then call myThread.join(5000) so I only wait around 5 seconds for the Connection. If it didn't return a Connection by then, resume processing in the main thread and abandon that Thread. Should I be concerned about a memory leak here and try to kill the thread somehow?

The cause:
The PostgreSQL server had a SCSI RAID backplane start to go bad, with lots of random disk errors. The drives on the bad backplane contained the OS and /usr/local/pgsql, but /usr/local/pgsql/data is on another backplane that was fine. The server would generally boot fine and operate normally until a disk error occured. At that point any Linux processes that tried to access drives on the bad backplane would just hang. The kernel still works since it's in memory, it will accept new TCP connections, all daemons are still running. Postgres itself still runs fine for existing connections, since the postmaster was loaded in memory and the data drives were still accessible on the good backplane. I presume that opening a new Connection would create a new pid, which the kernel would try to write to the bad drives....and hang.

The real question:
Is there a connection timeout in the JDBC driver? Should there be? This seems like a reasonable situation to provide handling for.

Thanks for listening to my problem!

Roman Fail
POS Portal, Inc.
916-563-1943


Browse pgsql-jdbc by date

  From Date Subject
Next Message Scot Floess 2003-07-03 19:11:23 Re: No timeout to establish Connection?
Previous Message Kim Ho 2003-07-03 18:35:19 UPDATED Re: ToBoolean method return correct Boolean values as per JDBC spec