[SERVER-26802] MongoCollection.Count() is not correct Created: 27/Oct/16  Updated: 27/Oct/16  Resolved: 27/Oct/16

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

Type: Bug Priority: Major - P3
Reporter: Hu Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File TestCSharp1812.PNG     Zip Archive TestCSharp1812.zip    
Operating System: ALL
Steps To Reproduce:

unzip the TestCSharp1812.
Edit the bat file and run the bat file.
MongoBooster places contains 2 records,but the status of collection,count is 1.

Participants:

 Description   

I do not know how to reproduce the problem collection,
So I send you my test database and run.bat file.
In my MongoBooster Database,there are two Collection
places and place2 , you will find there are 2 records in it.
But the first collection Status Count is 1 while the second is 2.

I also send you the hardcopy of MongoBooster.
You can find the document is 2,and the number beside the Colname is (1)



 Comments   
Comment by Hu [ 27/Oct/16 ]

Great!
The problem disappered after avlidate command!

Comment by Stennie Steneker (Inactive) [ 27/Oct/16 ]

Hi,

Thank you for providing log files and a sample database to demonstrate the problem.

From the log file it appears you had an unclean shutdown, which can result in WiredTiger collection counts being inaccurate.

Fast collection counts in WiredTiger (i.e. counts without a query predicate) are only periodically persisted, so following an unclean shutdown you may need to validate the collection stats to true up counts: https://docs.mongodb.com/manual/reference/method/db.collection.count/#accuracy-after-unexpected-shutdown.

For your specific case, you could run:

  use MongoBooster
  db.places.validate(true)

Additionally, I noticed you have disabled the journal which may result in some data modifications being lost in the event of unexpected shutdown: https://docs.mongodb.com/manual/core/wiredtiger/#storage-wiredtiger-journal. I would generally recommend leaving the journal enabled.

Note: the SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For MongoDB-related support discussion, please post on the mongodb-user group (https://groups.google.com/group/mongodb-user) or Stack Overflow with the mongodb tag.

Regards,
Stephen

Generated at Thu Feb 08 04:13:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.