Uploaded image for project: 'Commons Pool'
  1. Commons Pool
  2. POOL-356

deadlock if borrowObject gets called to fast and maxIdle is 0

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.6.0
    • Fix Version/s: 2.6.1
    • Labels:
      None

      Description

      I figured this while creating a unit test for OpenJPA. But also did see this in real production with commons-dbcp2. See DBCP-513 for more info.

      See this comment for a precise explanation what happens https://issues.apache.org/jira/browse/DBCP-513?focusedCommentId=16660545&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16660545

      The problem is basically that the logic to immediately destroy a pool object does not notify the DeLinkedQueue:

              if (isClosed() || maxIdleSave > -1 && maxIdleSave <= idleObjects.size()) {
                  try {
                      destroy(p);
      

      But the borrowObject code is locking on that condition...

                          if (borrowMaxWaitMillis < 0) {
                              p = idleObjects.takeFirst();
                          } 
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                struberg Mark Struberg
                Reporter:
                struberg Mark Struberg
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m