getConnection hanging: Timed out waiting for a free available connection.

Bug #1318266 reported by Alexey Panteleev
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
BoneCP
New
Undecided
Unassigned

Bug Description

I am experiencing a similar issue with 0.8 release, JVM7.

ds.setLazyInit(true);
ds.setPartitionCount(1);
ds.setMinConnectionsPerPartition(1);
ds.setMaxConnectionsPerPartition(45);
ds.setAcquireIncrement(1);

// Half of the MySQL default
ds.setMaxConnectionAgeInSeconds(14400);
ds.setConnectionTimeoutInMs(3 * javax.management.timer.Timer.ONE_MINUTE);

ds.setCloseOpenStatements(true);
ds.setDetectUnclosedStatements(true);

Two threads are asking BoneCP for a new connection and at some point getConnection hangs:

17:04:02.839 [pool-2-thread-1] > Getting connection A
17:04:02.839 [pool-2-thread-2] > Getting connection B
17:04:02.979 [pool-2-thread-1] < Got connection A
17:04:03.260 [pool-2-thread-1] > Getting connection C
17:04:03.672 [pool-2-thread-2] < Got connection B

 The C connection is never returned:

java.sql.SQLException: Timed out waiting for a free available connection.
     at com.jolbox.bonecp.DefaultConnectionStrategy.getConnectionInternal(DefaultConnectionStrategy.java:88) ~[bonecp-0.8.0.RELEASE.jar:na]
     at com.jolbox.bonecp.AbstractConnectionStrategy.getConnection(AbstractConnectionStrategy.java:90) ~[bonecp-0.8.0.RELEASE.jar:na]
     at com.jolbox.bonecp.BoneCP.getConnection(BoneCP.java:553) ~[bonecp-0.8.0.RELEASE.jar:na]
     at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:131) ~[bonecp-0.8.0.RELEASE.jar:na]
     at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:157) ~[bonecp-0.8.0.RELEASE.jar:na]

Any ideas? Not clear if it's a locking issue of the BlockingQueue or the PoolWatcher thread stops supplying new connections.

Setting partion=2 resolves this but then I am not sure if I will experience this with 3 or more threads.
Setting minConnections to >1 also helps but then I am not sure if we don't hit this deadlock later on when those are exhausted.

-Alexey

Revision history for this message
Alexey Panteleev (alexey-0) wrote :

Experiencing this issue with the following settings also

ds.setPartitionCount(3);
ds.setMinConnectionsPerPartition(3);
ds.setMaxConnectionsPerPartition(20);
ds.setAcquireIncrement(3);

 When >3 threads ask for a new connection BoneCP gets into some kind of a deadlock.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.