[SERVER-11815] __getitem__ send a limit of -1 Created: 21/Nov/13 Updated: 06/Dec/22 Resolved: 06/Dec/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Sharding |
| Affects Version/s: | 2.2.4, 2.4.8 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | xbsura | Assignee: | [DO NOT USE] Backlog - Sharding Team |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
mongodb 2.2.4 |
||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Sharding
|
||||||||
| Operating System: | ALL | ||||||||
| Participants: | |||||||||
| Description |
|
db.collection.find().limit(-1) and db.collection.find().limit(1) is equivalent in mongo 2.4.7,but our mongo being used is 2.2.4.We found that sometimes limit(-1) is different with limit(1) when querying. if isinstance(index, (int, long)): |
| Comments |
| Comment by Gregory McKeon (Inactive) [ 06/Dec/18 ] | ||
|
Closing as it should have gone away with the find changes in 3.2 - if you still have this issue, please open a new SERVER ticket. | ||
| Comment by Jeffrey Yemin [ 11/Dec/13 ] | ||
|
This has been reported again in | ||
| Comment by A. Jesse Jiryu Davis [ 21/Nov/13 ] | ||
|
This appears to be a bug in the 2.2 series of mongos that was fixed in the 2.4 series. | ||
| Comment by xbsura [ 21/Nov/13 ] | ||
|
yes,in mongodb 2.2.4,the two querying is different sometime. in some cases,limit(-1) and limit(1) return different results. mongos> db.x_000.find().skip(14620).limit(-1) { "_id" : ObjectId("5203ca94b78b27064d8be140"), "idx" : 75042, "random" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "name" : "testms_insert_75042" }mongos> db.x_000.find().skip(14620).limit(1) { "_id" : ObjectId("520497a4b78b2757cab83ff1"), "idx" : 25259, "random" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "name" : "testms_insert_25259" }even sort({_id:1}),they are still different. | ||
| Comment by A. Jesse Jiryu Davis [ 21/Nov/13 ] | ||
|
There is a reason PyMongo sends a limit of -1 instead of 1. For small limits, a negative number is much more efficient. See the documentation for numberToReturn for more information. It sounds like you're seeing a bug in the MongoDB server 2.2 series, that was fixed in the 2.4 series. Could you please try to reproduce it using the mongo shell, or another driver besides PyMongo? You'll need to find a query for which PyMongo returns null every time with a limit of -1, and returns the correct document every time with a limit of 1. Then run the same query in the mongo shell:
... and see if you can reproduce the incorrect behavior with MongoDB 2.2.4. |