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

singleBatch can return incomplete results in a sharded environment

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 3.4.0-rc1
    • 3.2.9
    • 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

    Description

      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.

      Attachments

        Activity

          People

            maria.vankeulen@mongodb.com Maria van Keulen
            christopher.harris@mongodb.com Chris Harris
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: