EasyBeans

JDBCPool Doesn't renew timedout connections (Validity check wrong with checkLevel=1)

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: EasyBeans 1.1.0 M1
  • Fix Version/s: EasyBeans 1.1.0 M3
  • Component/s: DB Pool
  • Description:
    Hide
    On the presented environment, the JDBCPool does not renew expired connections to the database.
    This is due to the fact that the IConnection.isPhysicallyClosed() method called to check the validity doesn't report a consistent state, a real failing operation has to be performed to see this parameter correctly updated.

    Anyway, the Connection Interface provides the isValid(int timeout) method that enforces any implementation to perform an operation that would really check the link to the database server...a call to that method updates the isPhysicallyClosed() parameter as well.

    Thanks to the clear organisation of the Easybean project, I wrote a really simple fix (posted in a patch) that just double checks connections (with checkLevel=1) with IConnection.isPhysicallyClosed() and Connection.isValid(1).

    That could be a good idea to include that small fix into the Head revision (if not already done by someone though)

    Thanks.
    Cheers

    Richard
    Show
    On the presented environment, the JDBCPool does not renew expired connections to the database. This is due to the fact that the IConnection.isPhysicallyClosed() method called to check the validity doesn't report a consistent state, a real failing operation has to be performed to see this parameter correctly updated. Anyway, the Connection Interface provides the isValid(int timeout) method that enforces any implementation to perform an operation that would really check the link to the database server...a call to that method updates the isPhysicallyClosed() parameter as well. Thanks to the clear organisation of the Easybean project, I wrote a really simple fix (posted in a patch) that just double checks connections (with checkLevel=1) with IConnection.isPhysicallyClosed() and Connection.isValid(1). That could be a good idea to include that small fix into the Head revision (if not already done by someone though) Thanks. Cheers Richard
  • Environment:
    Mysql 5.0.51a-5 (Debian Lenny/testing most recent)
    Mysql JDBC Connector 5.1.6 (recommended version)
    Linux Debian Lenny/testing, && Windows Vista

    EasyBeans used as embedded (own Application Server)
  1. jdbcrenewpath.patch
    (1 kB)
    Richard Leys
    26/Dec/08 12:02 AM

Activity

Hide
Richard Leys added a comment - 26/Dec/08 12:02 AM
Patch containing the one line (!) modification to solve the issue.
Apply in module root (where the pom.xml is)
Show
Richard Leys added a comment - 26/Dec/08 12:02 AM Patch containing the one line (!) modification to solve the issue. Apply in module root (where the pom.xml is)
Hide
Florent BENOIT added a comment - 05/Jan/09 6:05 PM
Thanks for the patch.
One of the problem is that EasyBeans needs to compile with either JDK 5 or 6.
But the isValid(int timeout) method is only available by using JDK 6
So if the patch is applied, it doesn't compile/work on a JDK 5.

By using a checkLevel of 2, a statement is executed on the remote side so this can work as you are expecting it but maybe you still want a checkLevel of 1 ?

I need some time to adapt the patch for both JDK. You can also propose a patch that work for JDK 5+

Thanks for your report and happy new year ;-)
Show
Florent BENOIT added a comment - 05/Jan/09 6:05 PM Thanks for the patch. One of the problem is that EasyBeans needs to compile with either JDK 5 or 6. But the isValid(int timeout) method is only available by using JDK 6 So if the patch is applied, it doesn't compile/work on a JDK 5. By using a checkLevel of 2, a statement is executed on the remote side so this can work as you are expecting it but maybe you still want a checkLevel of 1 ? I need some time to adapt the patch for both JDK. You can also propose a patch that work for JDK 5+ Thanks for your report and happy new year ;-)
Hide
Richard Leys added a comment - 06/Jan/09 9:57 AM
I didn't know isValid() was only available on JDK6 :)

I tried the checkLevel 2, but it seems that the default executed statement is NULL, and the MySQL driver doesn't like this very much. A good solution could be to adapt the executed statement to make it more compatible for people running on JDK5...I'll try to see what I can do as soon as possible.

Happy new year to you too :)
Cheers.


Show
Richard Leys added a comment - 06/Jan/09 9:57 AM I didn't know isValid() was only available on JDK6 :) I tried the checkLevel 2, but it seems that the default executed statement is NULL, and the MySQL driver doesn't like this very much. A good solution could be to adapt the executed statement to make it more compatible for people running on JDK5...I'll try to see what I can do as soon as possible. Happy new year to you too :) Cheers.
Hide
Florent BENOIT added a comment - 06/Feb/09 1:46 PM
Problem fixed by allowing to define in the JDBCPool component XML configuration the test statement.
Then with the correct checkLevel value, the test statement will be executed.
The default statement is "select 1 from INFORMATION_SCHEMA.SYSTEM_USERS" (as hsqldb is provided by EasyBeans)
Show
Florent BENOIT added a comment - 06/Feb/09 1:46 PM Problem fixed by allowing to define in the JDBCPool component XML configuration the test statement. Then with the correct checkLevel value, the test statement will be executed. The default statement is "select 1 from INFORMATION_SCHEMA.SYSTEM_USERS" (as hsqldb is provided by EasyBeans)
Hide
Florent BENOIT added a comment - 06/Feb/09 1:47 PM
fixed
Show
Florent BENOIT added a comment - 06/Feb/09 1:47 PM fixed

People

Dates

  • Created:
    25/Dec/08 11:58 PM
    Updated:
    16/Feb/10 8:00 PM
    Resolved:
    06/Feb/09 1:46 PM