Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-88225

Repairing a unique index with duplicates may not work with old format indexes

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.0.0-rc0
    • 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.

            Assignee:
            louis.williams@mongodb.com Louis Williams
            Reporter:
            louis.williams@mongodb.com Louis Williams
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: