-
Type: Bug
-
Resolution: Done
-
Priority: Critical - P2
-
Affects Version/s: 3.0.0
-
Component/s: WiredTiger
-
None
-
Fully Compatible
-
ALL
-
-
Quint Iteration 7
ISSUE SUMMARY
Truncating a capped collection using the WiredTiger storage engine may not remove the deleted documents from the indexes in the collection.
USER IMPACT
When running the captrunc command on a capped collection, or when a member of a replica-set does a rollback of such a collection, the removed documents may not be deleted from the collection's indexes, thus leaving the indexes in an inconsistent state. As a result, a query covered by an index may report results that include deleted documents, and queries using an index in general may fail or return incorrect results. Regular deletions as result of exceeding capped collection capacity are not affected by this issue.
To determine if a capped collection is impacted by this issue, users can compare the output of the following commands:
- db.cappedcollection.distinct("_id").length
- db.cappedcollection.count()
If the results are equal the capped collection is not impacted by this issue. Alternatively, users can compare the nrecords and keysPerIndex fields of the db.cappedcollection.validate() output in the mongo shell; if the values are equal then the capped collection is not impacted.
WORKAROUNDS
Users may run the reIndex command on the affected capped collections. This restores consistency in the collection's indexes, but does not prevent the issue from happening again.
AFFECTED VERSIONS
MongoDB versions 3.0.0 through 3.0.4 using the WiredTiger storage engine.
FIX VERSION
The fix is included in the 3.0.5 production release.
Original description
The captrunc command does not unindex documents removed from a WiredTiger capped collection. As rollback operations in a replicaset are performed using this command, they can leave indexes in an inconsistent state.