EasyBeans is an open source implementation by ObjectWeb of the EJB3 container specification. 
X Wiki
  History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: EZB-327
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Florent BENOIT
Reporter: Richard Leys
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
EasyBeans

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

Created: 25/Dec/08 11:58 PM   Updated: 16/Feb/10 08:00 PM
Component/s: DB Pool
Affects Version/s: EasyBeans 1.1.0 M1
Fix Version/s: EasyBeans 1.1.0 M3

File Attachments: 1. Text File jdbcrenewpath.patch (1 kb)

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)


 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

 All   Comments   Change History   Related Builds      Sort Order:
Richard Leys - 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)

Florent BENOIT - 05/Jan/09 06: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 ;-)

Richard Leys - 06/Jan/09 09: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.



Florent BENOIT - 06/Feb/09 01: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)

Florent BENOIT - 06/Feb/09 01:47 PM
fixed


Copyright © 2006-2007 EasyBeans / ObjectWeb consortium

http://www.easybeans.org