singleBatch can return incomplete results in a sharded environment

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 3.4.0-rc1
    • Affects Version/s: 3.2.9
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • Hide

      In a sharded environment, insert more than 101 documents with the same value for the shard key into a collection. Issuing a find command which includes the parameter singleBatch:true to a mongos will not return any results to the client. Issuing the command with singleBatch:true removed will return 101 documents as expected.

      mongos> sh.shardCollection('test.foo',{x:1})
      { "collectionsharded" : "test.foo", "ok" : 1 }
      mongos> for(i = 1; i < 250; i++){ db.foo.insert({x:0});}
      WriteResult({ "nInserted" : 1 })
      mongos>
      mongos> db.foo.runCommand({find:"foo", filter:{x:0}, skip:101, singleBatch: true}).cursor.firstBatch.length
      0
      mongos> db.foo.runCommand({find:"foo", filter:{x:0}, skip:101}).cursor.firstBatch.length
      101
      
      Show
      In a sharded environment, insert more than 101 documents with the same value for the shard key into a collection. Issuing a find command which includes the parameter singleBatch:true to a mongos will not return any results to the client. Issuing the command with singleBatch:true removed will return 101 documents as expected. mongos> sh.shardCollection('test.foo',{x:1}) { "collectionsharded" : "test.foo", "ok" : 1 } mongos> for(i = 1; i < 250; i++){ db.foo.insert({x:0});} WriteResult({ "nInserted" : 1 }) mongos> mongos> db.foo.runCommand({find:"foo", filter:{x:0}, skip:101, singleBatch: true}).cursor.firstBatch.length 0 mongos> db.foo.runCommand({find:"foo", filter:{x:0}, skip:101}).cursor.firstBatch.length 101
    • Query 2016-10-10, Query 2016-10-31
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In a sharded environment, mongos will pass along the singleBatch:true parameter to the mongod shards. This results in no cursor being sent back to mongos. If mongos is unable to fill the result set requested by the client using the documents returned by the initial batches from the shards then incomplete results will be returned to the client since there are no cursors to issue `getMore` commands against.

            Assignee:
            Maria van Keulen
            Reporter:
            Chris Harris
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: