Bug 54978 - Validate on Borrow should be tested on Reconnect instead of Validate On Connect
Validate on Borrow should be tested on Reconnect instead of Validate On Connect
Status: RESOLVED FIXED
Product: Tomcat Modules
Classification: Unclassified
Component: jdbc-pool
unspecified
PC Linux
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2013-05-15 19:30 UTC by tim.poole
Modified: 2014-08-07 23:16 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tim.poole 2013-05-15 19:30:25 UTC
If testOnBorrow is set true, testOnConnect is false, and validationQuery is an illegal query, the current implementation will hide the fact that validationQuery never succeeds.

The offending code is in org.apache.tomcat.jdbc.pool.ConnectionPool line 797.

790            //if we reached here, that means the connection
791	            //is either has another principal, is discarded or validation failed.
792	            //we will make one more attempt
793	            //in order to guarantee that the thread that just acquired
794	            //the connection shouldn't have to poll again.
795	            try {
796	                con.reconnect();
797	                if (con.validate(PooledConnection.VALIDATE_INIT)) {

Instead, con.validate(PooledConnection.VALIDATE_BORROW) should be called.
Comment 1 tim.poole 2013-05-16 13:23:20 UTC
Or better, something akin to con.validate(PooledConnection.VALIDATE_INIT | PooledConnection.VALIDATE_BORROW).
Comment 2 Filip Hanik 2014-08-07 23:16:34 UTC
Thank you for the report, tricky indeed.

Fixed in r1616625