[SERVER-3567] mongos doesn't handle negative limits correctly Created: 10/Aug/11  Updated: 11/Jul/16  Resolved: 17/Nov/11

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 1.8.2
Fix Version/s: 2.1.0

Type: Bug Priority: Major - P3
Reporter: Robert Stam Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Operating System: ALL
Participants:

 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.



 Comments   
Comment by auto [ 17/Nov/11 ]

Author:

{u'login': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: test for SERVER-3567
Branch: master
https://github.com/mongodb/mongo/commit/d800b9548e2196f2677870337de017b8b1779e6f

Generated at Thu Feb 08 03:03:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.