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

From Scot Floess
Subject Re: No timeout to establish Connection?
Date
Msg-id 869ECA4E976BD611986F00508B553FA002A323C8@DSMAIL4
Whole thread Raw
In response to No timeout to establish Connection?  ("Roman Fail" <rfail@posportal.com>)
List pgsql-jdbc
Roman:

I really don't have an answer to this...but I would like to make a comment.
You "think" that your code is stuck in DriverManager.getConnection().  To
confirm, you can issue a kill -QUIT on the pid of the java process.  This
will give you a thread dump of all threads...which will include what methods
are currently executing.  If you do this twice over a period of time you
might better see where the problem is...for instance it may not be
DriverManager.getConnection().

Again, I really don't have an answer but I find issuing the kill -QUIT <PID>
to be very useful when debugging java problems...

Scot

-----Original Message-----
From: Roman Fail [mailto:rfail@posportal.com]
Sent: Thursday, July 03, 2003 2:40 PM
To: pgsql-jdbc@postgresql.org
Subject: [JDBC] No timeout to establish Connection?


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



---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org

pgsql-jdbc by date:

Previous
From: Kim Ho
Date:
Subject: JDBC Driver: Check for closed statement
Next
From: Darin Ohashi
Date:
Subject: java.sql.SQLException: 1 >= 1