commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glenn Nielsen <gl...@voyager.apg.more.net>
Subject [DBCP] Connection.close() of already closed connections
Date Sat, 29 Jun 2002 17:00:58 GMT
When DBCP closes a db Connection the object is recyled back into
the pool and made available for reuse.  When being used inside
a threaded container like Tomcat it is possible for the following
to happen:

Thread for Request A gets a db connection
Thread for Request A does some work with the db
Thread for Request A closes the db connection
Thread for Request B gets a db connection
  (the same connection Request A just closed)
Due to a bug (most likely an Exception handling bug),
  Thread for Request A closes the db connection again
Thread for Request B tries to use the db connectin,
  Thread B gets an SQLException "Connection is closed."

Solution:

Which thread opened a db connection should be tracked.
DelegatingConnection.close() should then ignore the
close request if the currentThread is not the same
Thread which opened the connection.

A separate closeAbandoned() method would be available to allow the code
which removes abandoned connections to force closure of a connection
even though a different thread is requesting it.

Comments?

Regards,

Glenn

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message