Forgive my lack of familiarity with Proxool's architecture, but we've had
some issues with closing connections multiple times (with other pools as
well as proxool) and I want to understand where proxool sits in respect to
this issue currently.
Thread 1 gets a connection from the pool ... what it has is a
Connection-implementing proxy for the underlying driver-supplied Connection.
Thread 1 uses the Connection-proxy just like a normal Connection then calls
close() on it.
Thread 2 gets a connection from the pool, and let's say it's the same
underlying Connection Thread 1 just returned to the pool. Might it also be
the same instance of the Connection-proxy? If so, that's almost surely
trouble, as Thread 1 might still have a reference to it and call close() a
second time, thereby returning it to the pool and allowing some other thread
to get it while Thread 2 is still using it.
If the instance of the Connection-proxy is NOT the same one, then this
problem goes away: calling close() returns the underlying Connection to the
pool and can set the state of the Connection proxy so that any subsequent
attempt to use it can throw "SQLException: connection already closed" or
something like that.
-john.
-----Original Message-----
From: Bill Horsman [mailto:bi...@lo...]
Sent: Thursday, February 05, 2004 11:19 AM
To: Proxool
Subject: [Proxool-developer] Connections closed and open
Hi all,
Just investigating what happens when you close a connection twice. At
the moment, nothing bad happens but you get a nasty warning message
like:
ConnectionPool.java:356) - Unable to set status of connection 40 from
ACTIVE to AVAILABLE. It remains AVAILABLE
We should obviously spot that. I'll have to check but I believe that is
okay to close() twice and if you do then it should do so silently.
It also got me thinking. I don't think we check the connection status
when using it. So it is quite possible to close the connection (i.e.
return it to the pool) and then keep on using it. This would be unwise.
Perhaps we should be throwing an exception if you try to do anything to
a connection that has been closed.
But then, what happens if someone else grabs that connection? Then two
"users" could be using the same one. I'm not sure how to avoid that
problem. Perhaps that is something that the user has to avoid.
Our goal is to behave exactly as if you were using the driver directly
without a pool. And in that scenario the driver would spot it happening
and throw an exception.
I can't think of a solution to this. Maybe it's just something to
document.
- Bill
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Proxool-developer mailing list
Pro...@li...
https://lists.sourceforge.net/lists/listinfo/proxool-developer
|