[JAVA-1882] Driver can exhaust query pool if limit is reached on the first batch of a query Created: 08/Jul/15  Updated: 16/Jul/15  Resolved: 10/Jul/15

Status: Closed
Project: Java Driver
Component/s: Query Operations
Affects Version/s: 3.0.2
Fix Version/s: 3.0.3, 3.1.0

Type: Bug Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-19273 Short range scan using YCSB cause mon... Closed

 Description   

When a user specifies a limit on a find operation, and that limit is reached on the initial batch returned from OP_QUERY, the driver immediately attempts to kill the cursor via OP_KILL_CURSOR after reading the initial batch. The problem is that it does so by pulling another connection from the pool before the connection that was used for the OP_QUERY has been released back to the pool. This effectively doubles the number of connections required for find operations that specify a limit, and in the worst case can cause starvation, where all threads are waiting for connections but none are available.



 Comments   
Comment by Jeffrey Yemin [ 16/Jul/15 ]

Fix is now available in the 3.0.3 release.

Comment by Githook User [ 09/Jul/15 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: When the limit is reached after the initial batch of results of a FindOperation, use the same connection that was used for the initial OP_QUERY to execute the OP_KILL_CURSOR. This will ensure that a thread never attempts to checkout more than one connection at a time.

JAVA-1882
Branch: 3.0.x
https://github.com/mongodb/mongo-java-driver/commit/34c2e2cffeef54949503ce5cd05594a81af6851a

Comment by Githook User [ 08/Jul/15 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: When the limit is reached after the initial batch of results of a FindOperation, use the same connection that was used for the initial OP_QUERY to execute the OP_KILL_CURSOR. This will ensure that a thread never attempts to checkout more than one connection at a time.

JAVA-1882
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/eb1d502a8a1042880fafb030aa9c7f639e850a50

Comment by Jeffrey Yemin [ 08/Jul/15 ]

Thanks to robert.j.moore@allanbank.com for identifying this issue while running the YCSB benchmark.

Generated at Thu Feb 08 08:55:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.