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

mongos doesn't handle negative limits correctly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 1.8.2
    • Fix Version/s: 2.1.0
    • Component/s: Sharding
    • Labels:
      None
    • Operating System:
      ALL

      Description

      Using one mongo shell, start up a sharded environment with two shards as follows:

      C:\mongodb\mongodb-win32-x86_64-1.8.2\bin>mongo --nodb
      MongoDB shell version: 1.8.2
      > var st = new ShardingTest(name = "sharded", shards = 2, mongoses = 1)
      ...
      > st.s
      connection to 127.0.0.1:31000

      Now using another mongo shell, attach to the mongos on port 31000 and run this test:

      C:\mongodb\mongodb-win32-x86_64-1.8.2\bin>mongo --port 31000
      MongoDB shell version: 1.8.2
      connecting to: 127.0.0.1:31000/test
      > use admin
      switched to db admin
      > db.runCommand(

      {enablesharding:"test"}

      )

      { "ok" : 1 }

      > db.runCommand({shardcollection:"test.test", key:{_id:1}})

      { "collectionsharded" : "test.test", "ok" : 1 }

      > use test
      switched to db test
      > db.test.insert({_id:1})
      > db.test.insert({_id:2})
      > db.test.insert({_id:3})
      > db.test.insert({_id:4})
      > db.test.insert({_id:5})
      > db.test.insert({_id:6})
      > db.test.find()

      { "_id" : 1 } { "_id" : 2 } { "_id" : 3 } { "_id" : 4 } { "_id" : 5 } { "_id" : 6 }

      > db.test.find().skip(4).limit(2)

      { "_id" : 5 } { "_id" : 6 }

      > db.test.find().skip(4).limit(-2)
      >

      The last find with a negative limit of -2 should have returned two documents also.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: