[JAVA-950] Wrong fetching with limit 1 on sharded environment Created: 20/Sep/13  Updated: 11/Dec/13  Resolved: 11/Dec/13

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: 2.11.2, 2.11.3
Fix Version/s: None

Type: Bug Priority: Critical - P2
Reporter: siarhei usau Assignee: Unassigned
Resolution: Done Votes: 6
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Win 7 64-bit
RAM 8 GB
Mongo 2.4.3
mongo-java-driver: 2.11.2 and 2.11.3


Attachments: File JAVA-950.json     Zip Archive TestOfSkipLimitFetching.zip     File create_local_shards.sh     HTML File log    
Issue Links:
Related
related to SERVER-11815 __getitem__ send a limit of -1 Closed

 Description   

1. Create three Mongo shards on local host. You can use attached file create_local_shards.sh. Be sure all shards are created successfully:

MongoDB shell version: 2.4.3
connecting to: test

{ "shardAdded" : "shard0000", "ok" : 1 } { "shardAdded" : "shard0001", "ok" : 1 } { "shardAdded" : "shard0002", "ok" : 1 } { "ok" : 1 } { "collectionsharded" : "shardTest.shardTest", "ok" : 1 }

2. Run main.java.sharding.test.Starter#main metod of TestOfSkipLimitFetching standalone app. On mine machine I see the range of empty responses for following skip-limits:

Skip 4000, Limit 1
Skip 5000, Limit 1
Skip 6000, Limit 1
Skip 7000, Limit 1
Skip 8000, Limit 1
Skip 9000, Limit 1
Skip 9999, Limit 1

Full log you can find in attach.

So as you see limit of one doc works well on small skip values (till 3000). Then from 4000 of skipped docs we faced with this issue - collection.find().skip(>=4000).limit(1) returns nothing.

NOTE: We can reproduce it only on sharded Mongo environment. Actually such behavior we reproduced on more than one machines (Unix and Win) with local shards and distributed between 12 different hosts.



 Comments   
Comment by Jeffrey Yemin [ 11/Dec/13 ]

Closing this, as it's not a Java driver bug. The driver is correctly setting numberToReturn to -1, and mongos is not returning a document, as it does when numberToReturn is 1.

Comment by Jeffrey Yemin [ 11/Dec/13 ]

I'm linking this to SERVER-11815, as I believe this to be a mongos bug not a java driver bug.

Comment by siarhei usau [ 05/Dec/13 ]

db version: v2.4.3 & v2.4.5
MongoS version: 2.4.3 & 2.4.5

Comment by Jeffrey Yemin [ 04/Dec/13 ]

Siarhei,

Can you respond to Jesse's question, please, so we can move this issue along?

Jeff

Comment by A. Jesse Jiryu Davis [ 21/Nov/13 ]

What versions of mongos and mongod are you running, please?

Comment by siarhei usau [ 20/Sep/13 ]

What TestOfSkipLimitFetching standalone app does:
1. Creates or connects to "shardTest" DB and empty it at the beginning.
2. Loads "json.json" file (at the root of project) and uses it as template for all documents of "shardTest" collection.
3. Uses hash value (UUID.randomUUID()) in document "_id" index. Exactly this indexed field is shard key (see create_local_shards.sh).
4. Creates 10000 documents.
5. Runs several fetches (collection.find().skip(..).limit(..)) for different skip-limit values.

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