Set database connection pool timeout

XMLWordPrintable

      When connection pool is empty then next thread requesting a connection waits for ever (Integer.MAX_VALUE milliseconds) to get the connection. It may lead to deadlocks:

      "btpool0-16456" prio=10 tid=0x00007f62387b2800 nid=0x6448 waiting on condition [0x00007f6251417000]
         java.lang.Thread.State: TIMED_WAITING (parking)
      	at sun.misc.Unsafe.park(Native Method)
      	- parking to wait for  <0x0000000681416d58> (a com.jolbox.bonecp.BoundedLinkedTransferQueue)
      	at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
      	at jsr166y.LinkedTransferQueue.awaitMatch(LinkedTransferQueue.java:691)
      	at jsr166y.LinkedTransferQueue.xfer(LinkedTransferQueue.java:600)
      	at jsr166y.LinkedTransferQueue.poll(LinkedTransferQueue.java:1068)
      	at com.jolbox.bonecp.BoundedLinkedTransferQueue.poll(BoundedLinkedTransferQueue.java:78)
      	at com.jolbox.bonecp.BoneCP.getConnection(BoneCP.java:500)
      	at com.jolbox.bonecp.provider.BoneCPConnectionProvider.getConnection(BoneCPConnectionProvider.java:180)
      	at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
      	at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
      	at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
      

      To make application more self healing sane timeout (60 secs) should be introduced for retrieving connection from pool.

      Workaround

      Timeout can be set manually in config.xml:

      ...
      <database ...>
              ...
              <parameters>
      bonecp.connectionTimeoutInMs=60000
              </parameters>
      </database
      

            Assignee:
            Unassigned
            Reporter:
            Cezary Zawadka
            Votes:
            3 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: