Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-20720

mongos should not establish a tailable cursor over an empty capped collection

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.1.8
    • Fix Version/s: 3.2.0-rc0
    • Component/s: Querying, Sharding
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Sprint:
      QuInt A (10/12/15)

      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
      }
      

        Attachments

          Activity

            People

            Assignee:
            yunhe.wang YunHe Wang
            Reporter:
            david.storch David Storch
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: