Invalid invoice returned by MongoDB (WiredTiger)

It sounds weird, and I hope I'm doing something wrong, but my MongoDB collection returns a counter alone in my collection.

I have a collection with (I'm sure) 359671 documents. However, the count () command returns 359670 documents.

I execute the count () command using the mongo shell:

rs0:PRIMARY> db.COLLECTION.count() 359670 

This is not true.

He does not find every document in my collection.

If I count the following query, I get the correct result:

 rs0:PRIMARY> db.COLLECTION.count({_id: {$exists: true}}) 359671 

I believe this is a bug in WiredTiger. As far as I know, each document has the same definition, the integer _id field from 0 to 359670 and the BinData field. I did not have this problem with an older storage engine (or Mongo 2, this could cause the problem).

Am I doing something wrong? I do not want to use the query {_id: {$ exists: true}}, since it takes 100 times to complete.

+5
source share
1 answer

According to this problem , this behavior can occur if mongodb crashes badly and does not close gracefully. If you do not issue any request, mongodb will probably just return to the collected statistics.

According to the article, calling db.COLLECTION.validate(true) should reset the counters.

+9
source

All Articles