[SERVER-5763] The _id index broken Created: 04/May/12  Updated: 15/Aug/12  Resolved: 24/Jun/12

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.0.2, 2.0.4
Fix Version/s: None

Type: Bug Priority: Blocker - P1
Reporter: Andrew Orsich Assignee: Scott Hernandez (Inactive)
Resolution: Incomplete Votes: 0
Labels: index, query, windows
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7, x64


Operating System: Windows
Participants:

 Description   

Hey,

I am trying to run following query:

     db.items.find({"_id": 2306})

This query suppose to return one document with id 2306, but it for some reason gives strange result:

    {"_id" : 1274,  ....}

It seems that something weird happens with default _id index, but I can't re-create it.
Let me know guys how I can help reproduce this issue or how I can solve it.

Thank you.



 Comments   
Comment by Scott Hernandez (Inactive) [ 07/May/12 ]

Not sure either. Could be index corruption. Did you ever run without journaling or is this data from pre-2.0.x ?

Were there any errors in the server logs when it gave the wrong results?

Comment by Andrew Orsich [ 07/May/12 ]

Here is explain before reindex:

{
	"cursor" : "BtreeCursor _id_",
	"nscanned" : 1,
	"nscannedObjects" : 1,
	"n" : 1,
	"millis" : 0,
	"nYields" : 0,
	"nChunkSkips" : 0,
	"isMultiKey" : false,
	"indexOnly" : false,
	"indexBounds" : {
		"_id" : [
			[
				2306,
				2306
			]
		]
	}
}

After reindex it works.. And explain looks same:

{
	"cursor" : "BtreeCursor _id_",
	"nscanned" : 1,
	"nscannedObjects" : 1,
	"n" : 1,
	"millis" : 0,
	"nYields" : 0,
	"nChunkSkips" : 0,
	"isMultiKey" : false,
	"indexOnly" : false,
	"indexBounds" : {
		"_id" : [
			[
				2306,
				2306
			]
		]
	}
}

Not sure what cause this issue.

Comment by Scott Hernandez (Inactive) [ 05/May/12 ]

Can you run db.items.find(

{"_id": 2306}

).explain() and post the results.

Also, you should be able to run db.items.reIndex() to regenerate all indexes (even the _id one). http://www.mongodb.org/display/DOCS/Index-Related+Commands#Index-RelatedCommands-ReIndex

If the results change after the reindex it would be good to see those explain results too.

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