[JAVA-1591] Setting DBCursor.batchSize() does not seem to work for certain queries. Created: 10/Dec/14 Updated: 10/Dec/14 Resolved: 10/Dec/14 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | 2.11.4, 2.12.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Severin Gehwolf | Assignee: | Ross Lawley |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Linux, x86_64, Fedora 20 |
||
| Attachments: |
|
| Description |
|
Disclaimer: Problem: I'm attaching a reproducer for this issue. The expected output should be similar to the following:
Actual output I get is:
If the tester.removeData() line gets commented out (i.e. keep data in the DB) one can reproduce the same results with the mongo shell. Code as follows:
That forEach() call also only prints 100 elements while myCursor.size() prints > 100 (e.g. 1077). The Java reproducer can be run via (provided a mongod is running on local host on port 27518):
|
| Comments |
| Comment by Ross Lawley [ 10/Dec/14 ] |
|
Hi, This is not an issue with the Java driver but rather you are hitting a known bug with MongoDB 2.4 ( The bug was when using both batchSize and sort on a cursor where the sort was on an unindexed field. This caused the cursor to return fewer items than it should. Barring an upgrade of MongoDB if you remove the sort or index the timestamp field or use the default batchSize and then it will work as expected. For future reference, a better place for questions regarding MongoDB usage or the Java driver specifics is the mongodb-user mailinglist or stackoverflow as you will reach a boarder audience there and should get a faster response. This JAVA project is specifically for driver based bugs or issues. Hope that helps, Ross |