ISSUE DESCRIPTION AND IMPACT
Background, unique, non-partial indexes on WiredTiger may build indexes that have mismatched keys. As a result, there may be index keys that point to documents without respective matching keys. It is possible that query results that use such an index may return invalid results. Despite this issue, the uniqueness constraint of the index is still maintained and no documents in the collection will violate the constraint.
DIAGNOSIS AND AFFECTED VERSIONS
Any user running WiredTiger who has created a background, unique, non-partial index on a non-empty collection prior to MongoDB 3.4.21, 3.6.13, or 4.0.10 while performing deletes or updates to the indexed fields during the index build may have been affected. Users can check the settings used to create an index by calling getIndexes on all of their collections.
Users who meet the above criteria should run validate against their collection to determine whether their indexes are invalid and need to be rebuilt on a version containing the fix for this issue. In MongoDB 3.4 and before, users should validate with the {full:true} option passed. In MongoDB 3.6 and 4.0, users need not specify {full:true} when invoking the validate command to identify this issue.
REMEDIATION AND WORKAROUNDS
The fix is included in the 3.4.21, 3.6.13, 4.0.10 production release. Affected users should upgrade to these versions and rebuild the invalid indexes.
Original description
{ "ns" : "test.hugeindex", "nInvalidDocuments" : NumberLong(0), "nrecords" : 23, "nIndexes" : 4, "keysPerIndex" : { "_id_" : 23, "a_1" : 20960, "a_1__id_1" : 20960, "_id_1_a_1" : 22958 }, "valid" : false, "warnings" : [ "Detected 1998 extra index entries.", "Some checks omitted for speed. use {full:true} option to do more thorough scan." ], "errors" : [ "Index with name '_id_1_a_1' has inconsistencies." ], "extraIndexEntries" : [ { "indexName" : "_id_1_a_1", "recordId" : NumberLong(11), "indexKey" : { "_id" : 10, "a" : 0 } }, { "indexName" : "_id_1_a_1", "recordId" : NumberLong(11), "indexKey" : { "_id" : 10, "a" : 2 } }, { "indexName" : "_id_1_a_1", "recordId" : NumberLong(11), "indexKey" : { "_id" : 10, "a" : 3 } }, <snip> { "indexName" : "_id_1_a_1", "recordId" : NumberLong(21), "indexKey" : { "_id" : 20, "a" : 998 } }, { "indexName" : "_id_1_a_1", "recordId" : NumberLong(21), "indexKey" : { "_id" : 20, "a" : 999 } } ], "missingIndexEntries" : [ ], "advice" : "A corrupt namespace has been detected. See http://dochub.mongodb.org/core/data-recovery for recovery steps.", "ok" : 1 }
- is duplicated by
-
SERVER-41803 Standalone server crash with 'Unique index cursor seeing multiple records for key { : null } '
- Closed
- related to
-
SERVER-22970 Background index build produces an index with mismatched index keys and documents
- Closed