-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Storage Execution
-
Fully Compatible
-
v7.0, v6.0, v5.0
-
Execution Team 2024-04-01
TLDR: Trying to fix an index inconsistency might not work in some cases for old-format unique indexes. Validate will report the error and rebuilding the index fixes the problem, provided duplicate keys are removed beforehand.
Attempting to repair an already inconsistent collection may not fix the problem. This is the same problem as SERVER-75922, but requires a much more limited set of requirements, and an existing index inconsistency:
- A non-_id unique index exists that was created in 4.0 or earlier.
- There is a document that has a unique value that was indexed in 4.0 or earlier.
- There are one or more documents that have the same value as this indexed document, but are not correctly indexed. This is a "missing index keys" inconsistency.
Removing the correctly indexed document will correctly remove the document and its indexed value. However, attempting to remediate the inconsistency may not fix the problem and create a different inconsistency:
- Removing one of the unindexed documents (by using the id index, for example), will remove the document, but _incorrectly remove the indexed key for the correctly indexed document. This creates a new "missing index key" inconsistency, in addition to the existing ones, without remediating the problem.
- Validate will report the new problem
- Rebuilding the index will not succeed as long as duplicate values exist in the collection. This is true regardless of this problem.
When can this happen?
- This is a problem with validate repair, but can also happen with manual intervention.
How can this be remediated?
- Delete all duplicate documents before rebuilding the index. This is already our recommended remediation step for inconsistencies.
- is related to
-
SERVER-88132 Build variant that injects for old format unique index keys
- Closed
- related to
-
SERVER-75922 Partial unique indexes created on MongoDB 4.0 can be missing index keys after upgrade to 4.2 and later, leading to uniqueness violations
- Closed