Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1873

ConnectionPoolStatisticsMBean reports incorrect wait queue size if some thread was not able to enter the queue

      com.mongodb.connection.DefaultConnectionPool::get invoke ConnectionPoolListener::waitQueueEntered only when it is actually possible to enter the queue (waitQueueSize <= MaxWaitQueueSize), but ConnectionPoolListener::waitQueueExited is invoked in finally clause every time DefaultConnectionPool::get is invoked (https://github.com/mongodb/mongo-java-driver/blob/master/driver-core/src/main/com/mongodb/connection/DefaultConnectionPool.java#L84).

      As a result, every time MongoWaitQueueFullException is thrown due to full wait queue, waitQueueSize in com.mongodb.management.ConnectionPoolStatistics is decremented. And eventually it may become negative.

      I've hit this issue with pretty old 2.12.4 driver, but according to sources it should be reproducible with latest driver.

      Suggested fix in attachment.

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            fzhinkin Filipp Zhinkin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: