No timeout to establish Connection? - Mailing list pgsql-jdbc

From Roman Fail
Subject No timeout to establish Connection?
Date
Msg-id 9B1C77393DED0D4B9DAA1AA1742942DA3BCC69@pos_pdc.posportal.com
Whole thread Raw
List 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
PostgreSQLserver is a separate machine running 7.3.1, also on Linux.  (Of course I plan on upgrading to 7.3.3 and the
latestJDBC driver ASAP).
 
 
The symptom:
Tomcat would almost completely crash whenever the Postgres database was accessed.  While I did not have time to fully
quantifythe exact Java problem, it appears that the opening of a new Connection set caused the crash.  (Note, JVM did
notcrash, just all the webapps).  My guess is that the the DriverManager.getConnection(...) statement just runs and
runsbut 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
5seconds for the Connection.  If it didn't return a Connection by then, resume processing in the main thread and
abandonthat 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
badbackplane contained the OS and /usr/local/pgsql, but /usr/local/pgsql/data is on another backplane that was fine.
Theserver would generally boot fine and operate normally until a disk error occured.  At that point any Linux processes
thattried to access drives on the bad backplane would just hang.  The kernel still works since it's in memory, it will
acceptnew TCP connections, all daemons are still running.  Postgres itself still runs fine for existing connections,
sincethe postmaster was loaded in memory and the data drives were still accessible on the good backplane.  I presume
thatopening 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
handlingfor.  
 
 
Thanks for listening to my problem!
 
Roman Fail
POS Portal, Inc.
916-563-1943
 
 

pgsql-jdbc by date:

Previous
From: Fernando Nasser
Date:
Subject: Re: Please help with binary file
Next
From: Kim Ho
Date:
Subject: UPDATED Re: ToBoolean method return correct Boolean values as per JDBC spec