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
}