[SERVER-16126] find cursor don't return documents but count() does Created: 13/Nov/14  Updated: 15/Jan/15  Resolved: 15/Jan/15

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 2.6.5
Fix Version/s: None

Type: Bug Priority: Critical - P2
Reporter: Myoungki Kim Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

Some document updates in sharded collection.

db.collection.find({ng:{$exists:false}}).count()
> 75950
db.collection.find({ng:{$exists:false}})
> Empty

Participants:

 Description   

I ran following queries but it returns strange values. This makes inconsistency in the result.



 Comments   
Comment by Ramon Fernandez Marina [ 15/Jan/15 ]

mkim, since this is the expected behavior when using count() against a mongos I'm going to close this ticket.

For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag, where your question will reach a larger audience. A question like this involving more discussion would be best posted on the mongodb-user group.

Regards,
Ramón.

Comment by Myoungki Kim [ 14/Nov/14 ]

The query ran on mongos.

I have searched similar issues and found that it is because there are some shards which has 'nChunkSkips' values.

If this is the cause of this problem, how can I check the migration has been finished or not ? Is there any collection which has this information ?

{
"cursor" : "BasicCursor",
"n" : 402829886,
"nChunkSkips" : 47440889,
"nYields" : 5195594,
"nscanned" : 450270775,
"nscannedAllPlans" : 450270775,
"nscannedObjects" : 450270775,
"nscannedObjectsAllPlans" : 450270775,
"millisShardTotal" : 3808270,
"millisShardAvg" : 200435,
"numQueries" : 19,
"numShards" : 19,
"millis" : 306738
}

Comment by Ramon Fernandez Marina [ 13/Nov/14 ]

mkim, what are you running that query against? A mongos? A primary? A secondary? Also, how many documents are you expecting to match the query?

Note that when run against a mongos, count() may return incorrect results. Can you send us the output of:

db.collection.find({ng:{$exists:false}}).explain()

?

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