[SERVER-26334] Mongos leaves cursor open for legacy OP_QUERY find with ntoreturn of 1 Created: 26/Sep/16  Updated: 19/Nov/16  Resolved: 28/Sep/16

Status: Closed
Project: Core Server
Component/s: Querying, Sharding
Affects Version/s: 3.2.9, 3.3.14
Fix Version/s: 3.4.0-rc0

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

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Query 2016-10-10
Participants:
Linked BF Score: 0

 Description   

In the legacy OP_QUERY find protocol, an ntoreturn of 1 is special because it requires the server to close the cursor after retrieving the result. The new mongos query path introduced in 3.2 fails to handle this case correctly. This can be reproduced with the following script, run through a shell with --readMode legacy:

db.c.drop();
db.c.insert({_id: 1});
db.c.insert({_id: 2});
 
var cursor = db.c.find().limit(1);
if (cursor.hasNext()) { cursor.next(); }
 
// After retrieving the first result, serverStatus shows that
// mongos has left its cursor open.
db.serverStatus().metrics.cursor;
 
// If you ask the cursor whether it has another result,
// the shell will issue a getMore. In response to the getMore,
// mongos will close the cursor and return an empty batch.
cursor.hasNext();
db.serverStatus().metrics.cursor;

The mongod query path implements this correctly. If you run the above script directly against a mongod, the initial serverStatus will show that the mongod does not have an open cursor.



 Comments   
Comment by Githook User [ 28/Sep/16 ]

Author:

{u'username': u'cswanson310', u'name': u'Charlie Swanson', u'email': u'charlie.swanson@mongodb.com'}

Message: SERVER-26334 fix mongos handling of ntoreturn:1
Branch: master
https://github.com/mongodb/mongo/commit/9c8d1cf08ed9b0eeae08b490df67026af40982cd

Generated at Thu Feb 08 04:11:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.