[SERVER-4193] Cursor closed if limit is 1 Created: 02/Nov/11 Updated: 01/Aug/19 Resolved: 30/Apr/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Sharding |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Alex Yakushev | Assignee: | Antoine Girbal |
| Resolution: | Cannot Reproduce | Votes: | 6 |
| Labels: | cursor, query | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
any |
||
| Operating System: | ALL |
| Participants: |
| Description |
|
If limit is 1, and batchsize is 0, DBApiLayer.chooseBatchSize will return -1, and the cursor will be closed as a result. in DBApiLayer.chooseBatchSize, I see Code to replicate DB m = Mongo.connect(new DBAddress("host", "dbname")); DBCursor c1 = m.getCollection("mycoll").find(); System.out.println("Count 1 is: " + count1); DBCursor c2 = m.getCollection("buttons").find().skip(2).limit(1); System.out.println("Count 2 is: " + count2); Output: |
| Comments |
| Comment by Antoine Girbal [ 30/Apr/12 ] |
|
tried again, could not reproduce issue through Java driver with mongo 2.0.2. |
| Comment by Spencer Brody (Inactive) [ 29/Nov/11 ] |
|
I could not reproduce this in the shell or with pymongo, and given that changing an optimization in the java driver fixed the issue, I think this likely is an issue with the java driver, as was originally expected. Antoine, could you take another look and see if you can reproduce it on a sharded system? |
| Comment by Alex Yakushev [ 04/Nov/11 ] |
|
Server version 1.8.4 has the same problem |
| Comment by Alex Yakushev [ 02/Nov/11 ] |
|
Removing the optimization that I mentioned in the description from DBApiLayer.chooseBatchSize seems to fix the issue. |
| Comment by Alex Yakushev [ 02/Nov/11 ] |
|
Server version is 1.8.3 |
| Comment by Scott Hernandez (Inactive) [ 02/Nov/11 ] |
|
What server version are you using? This probably has nothing to do with java. |
| Comment by Alex Yakushev [ 02/Nov/11 ] |
|
Just discovered that the bug shows up only for sharded collections > db.runCommand( {enablesharding: "alex-test"}) { "ok" : 1 }> db.runCommand({shardcollection:"alex-test.buttons", key: {_id:1}}) { "collectionsharded" : "alex-test.buttons", "ok" : 1 }> use alex-test > db.buttons.find().skip(2).limit(1) { "_id" : ObjectId("4eb1025641dadce09bc24fb2"), "a" : 3 }Output of my test java code: (using mongo-2.7.0-rc1.jar) Running the same code on an unsharded collection: > db.fingers.find().skip(2).limit(1) { "_id" : ObjectId("4eb103c041dadce09bc24fb6"), "b" : 3 }Java output: |
| Comment by Antoine Girbal [ 02/Nov/11 ] |
|
ok that's odd, it works fine for me using 2.7 beta driver , "a" : 1.0} , "a" : 1.0} , "a" : 1.0} , "a" : 1.0} If I query with your options: , "a" : 1.0} could you try with the driver from git HEAD? |
| Comment by Alex Yakushev [ 02/Nov/11 ] |
|
I tried to change my silly db and collection names when I posted this example. Alas, now my secret is out, I was querying the "buttons" collection in both cases. It works when skip =0. With skip >0, it returns an empty cursor. |
| Comment by Antoine Girbal [ 02/Nov/11 ] |
|
I am not seeing this bug. |