-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: 2.12.4, 3.0.2
-
Component/s: Connection Management, Monitoring
-
None
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.