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

[5.0] IndexDescriptor::compareIndexOptions treats no unique/sparse as not identical to unique:false/sparse:false

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.28
    • Affects Version/s: 5.0 Required
    • Component/s: None
    • None
    • Storage Execution
    • Fully Compatible
    • ALL
    • Execution Team 2024-06-24, Execution Team 2024-07-08

      When we create an index we look up any existing index by the same name and compare the two index descriptors. If they are different we throw an IndexKeySpecsConflict error. If they are identical we return IndexAlreadyExists which is not an error condition. There's also an IndexOptionsConflict error condition where the key and uniquely-identifying options are equivalent to an existing index, but some other options are not identical.

      SERVER-47657 added 'unique' and 'sparse' parameters to index signature and gated this feature behind FCV 5.0. However, in doing so it introduced a bug that added 'unique' and 'sparse' to the options maps used for comparison. A nonexistent 'sparse' therefore compares unequal to false.

      To fix this bug, do not add unique/sparse to the options maps for comparison. Compare them as bool instead, in which nonexistent key is cast to false.

            Assignee:
            wei.hu@mongodb.com Wei Hu
            Reporter:
            wei.hu@mongodb.com Wei Hu
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: