[SERVER-20720] mongos should not establish a tailable cursor over an empty capped collection Created: 01/Oct/15  Updated: 15/Oct/15  Resolved: 08/Oct/15

Status: Closed
Project: Core Server
Component/s: Querying, Sharding
Affects Version/s: 3.1.8
Fix Version/s: 3.2.0-rc0

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

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: QuInt A (10/12/15)
Participants:

 Description   

This is a bug in the new mongos read path, and therefore affects only the master branch.

If a capped collection is empty, mongod will refuse to establish a tailable cursor since the position of the tailable cursor cannot be established. In this case, mongod will return a cursor id of 0 to the client. Mongos is expected to exhibit the same behavior. However, the new mongos read path establishes a broken tailable cursor that will never return any results:

mongos> db.c.drop()
mongos> db.createCollection("c", {capped: true, size: 1024})
 
// This should return a cursor id of 0, but instead returns a non-zero id.
mongos> db.runCommand({find: "c", tailable: true})
{
	"cursor" : {
		"id" : NumberLong("3460288308744221894"),
		"ns" : "test.c",
		"firstBatch" : [ ]
	},
	"ok" : 1
}
 
// If documents are inserted into the capped collection, they will not be returned by subsequent getMores against the mongos cursor.
mongos> db.c.insert({a: 1})
mongos> db.c.insert({a: 1})
mongos> db.c.insert({a: 1})
mongos> db.c.insert({a: 1})
mongos> db.runCommand({getMore: NumberLong("3460288308744221894"), collection: "c"})
{
	"cursor" : {
		"id" : NumberLong("3460288308744221894"),
		"ns" : "test.c",
		"nextBatch" : [ ]
	},
	"ok" : 1
}



 Comments   
Comment by Githook User [ 08/Oct/15 ]

Author:

{u'username': u'yhjw88', u'name': u'Yunhe (John) Wang', u'email': u'yunhe.wang@mongodb.com'}

Message: SERVER-20720 mongos now returns dead tailable cursor over an empty capped collection
Branch: master
https://github.com/mongodb/mongo/commit/aaf2969861e882624132c5d6b6141acfafc15aa7

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