Hi Justin,
Is this expected behavior and if so can someone provide me with an explanation so I’m not freaking about this anymore.
The count() command is generally an estimate of the current document count, based upon statistics provided by the storage engine.
After an unclean shutdown of a mongod using the WiredTiger storage engine, count statistics reported by count may be inaccurate. If this does occur you can run validate() on each collection to restore the correct statistics.
To accurately determine the current document count of a collection use the $group stage of the db.collection.aggregate() method to $sum the documents.
For example, the following query provides a real-time count of the documents in the oplog.rs collection:
db.getSiblingDB('local').oplog.rs.aggregate([{ $group: { _id : null, count : { $sum: 1 } } }])
Regards,
John Murphy