Hi all
I out checked the database pool and I found a possible deadlock situation:
Say for example the maximum number of connections has been reached and a
request for a connection arrives. It then goes into the following waiting
loop.
while (true)
{
if (!pool.empty())
{
// ..... Validation checks done here & connection returned
.....
}
else
{
connectionAttemptsCounter++;
}
wait();
}
Now suppose while the thread is waiting, another thread returns a database
connection, to the release method:
if ( isValid(connection) )
{
pool.push(connection);
notify();
}
else
{
closeConnection(connection);
totalConnections--;
}
If this connection happen to be invalid the notify() method is never
called, and the waiting thread will stay in a waiting state. If we assume
that a lot of similar request will be executed we can assume that a lot of
the returned connections will be invalid - starving the waiting thread(s).
A possible solution could be:
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/util/db/pool/Conne
ctionPool.java,v
retrieving revision 1.4
diff -r1.4 ConnectionPool.java
215c215,218
< connectionAttemptsCounter++;
---
> if (totalConnections<maxConnections)
> return getNewConnection(driver, url, username,
password);
> else
> connectionAttemptsCounter++;
295a299
> notify();
~ Leon
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]