Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.1.2
-
Fix Version/s: 2.1.3
-
Labels:None
-
Environment:Ubuntu 11.04, Mysql 5.1, BTM 2.1.2, Mysql-connector 5.1.18
-
Number of attachments :
Description
I am seeing that when a firewall drops the idle connection bitronix is not able to provide a valid connection. I am attaching a sample eclipse project BTMTest.zip.
Environment: Ubuntu 11.04, Mysql 5.1, BTM 2.1.2, mysql-connector 5.1.18
The sample program creates 10 min pool connections acquires them and releases them, then the current execution thread is made to sleep for 110 seconds. While the thread is sleeping, using the Mysql Administrator kill all the 10 connections. When the thread wakes up a request is made to acquire a connection and then error occurs. I see that there are about 8 tries made to get a valid connection from the pool and then BTM throws an error as shown below. I am not sure why it only tries for 8 times, in my opinion it should try till AcquisitionTimeout (30 sec). What is strange is that when I increase the thread sleep time to 120 seconds, a valid connection is obtained.
Here is the error printed on the eclipse console. For btm log please refer the log director with in the project.
java.sql.SQLException: unable to get a connection from pool of a PoolingDataSource containing an XAPool of resource jdbc/BPMSDB with 2 connection(s) (2 still available)
at bitronix.tm.resource.jdbc.PoolingDataSource.getConnection(PoolingDataSource.java:252)
at test.BTMTest.acquireConnections(BTMTest.java:57)
at test.BTMTest.main(BTMTest.java:99)
Caused by: bitronix.tm.internal.BitronixRuntimeException: cannot get valid connection from an XAPool of resource jdbc/BPMSDB with 2 connection(s) (2 still available) after trying for 30s
at bitronix.tm.resource.common.XAPool.getConnectionHandle(XAPool.java:162)
at bitronix.tm.resource.common.XAPool.getConnectionHandle(XAPool.java:97)
at bitronix.tm.resource.jdbc.PoolingDataSource.getConnection(PoolingDataSource.java:248)
... 2 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 117,142 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3102)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2991)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3532)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2002)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2624)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2127)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2293)
at bitronix.tm.resource.jdbc.JdbcPooledConnection.testConnection(JdbcPooledConnection.java:200)
at bitronix.tm.resource.jdbc.JdbcPooledConnection.getConnectionHandle(JdbcPooledConnection.java:286)
at bitronix.tm.resource.common.XAPool.getConnectionHandle(XAPool.java:136)
... 4 more
Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2552)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3002)
... 14 more
regards,
sathwik
When the AcquisitionInterval is set to 0, the program just waits for the connection to be returned from the pool forever.