[JAVA-1873] ConnectionPoolStatisticsMBean reports incorrect wait queue size if some thread was not able to enter the queue Created: 24/Jun/15 Updated: 16/Jul/15 Resolved: 15/Jul/15 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Connection Management, Monitoring |
| Affects Version/s: | 2.12.4, 3.0.2 |
| Fix Version/s: | 3.0.3, 3.1.0 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Filipp Zhinkin | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Description |
|
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. |
| Comments |
| Comment by Jeffrey Yemin [ 16/Jul/15 ] |
|
Fix is now available in the 3.0.3 release. |
| Comment by Githook User [ 15/Jul/15 ] |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: In the connection pool, moved wait queue size increment into its own try block so that wait queue start and end events are only delivered if the wait queue is actually entered. |
| Comment by Githook User [ 15/Jul/15 ] |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: In the connection pool, moved wait queue size increment into its own try block so that wait queue start and end events are only delivered if the wait queue is actually entered. |
| Comment by Githook User [ 15/Jul/15 ] |
|
Author: {u'username': u'fzhinkin', u'name': u'Filipp Zhinkin', u'email': u'filipp.zhinkin@gmail.com'}Message: Notify listener about wait queue enter before throwing an exception if the queue is full. |
| Comment by Githook User [ 15/Jul/15 ] |
|
Author: {u'username': u'fzhinkin', u'name': u'Filipp Zhinkin', u'email': u'filipp.zhinkin@gmail.com'}Message: Notify listener about wait queue enter before throwing an exception if the queue is full. |
| Comment by Jeffrey Yemin [ 24/Jun/15 ] |
|
Thanks Filipp, Would you like to open a pull request so that your name is associated with the fix in the Github commit? Regards, |