checkMetadataConsistency may return MissingShardKeyIndex false positive when migrating the first chunk to a shard

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.1.0-rc0
    • Affects Version/s: 8.3.0-rc0, 8.2.0, 9.0.0-rc0, 9.1.0-rc0
    • Component/s: Sharding
    • None
    • Catalog and Routing
    • Fully Compatible
    • ALL
    • v9.0, v8.3
    • Hide

      Run attached jstest.

      Show
      Run attached jstest.
    • CAR Team 2026-07-20
    • 200
    • 馃煡 DDL
    • None
    • None
    • None
    • None
    • None
    • None

      We only check that a sharded collection is supported by a valid shard key index under the optimistic check (only holding the DDL lock, but not collection locks). A chunk migration does not acquire the DDL lock, so checkMetadataConsistency may observes the intermediate state where the collection has been cloned by the MigrationDestinationManager but the indexes have not built yet.

      We should re-check the condition under the collection lock so that we serialize with chunk migrations. (This will serialize with the MigrationDestinationManager's corresponding lock.)

      This is a regression introduced by SERVER-99314 (v8.2+).

            Assignee:
            Joan Bruguera Mic贸
            Reporter:
            Joan Bruguera Mic贸
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: