[v8.0] shardCollection with hashed shard key may fail to evenly distribute chunks across shards when executed during an FCV downgrade

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: 8.0.0-rc0, 7.3.0
    • Component/s: None
    • None
    • Catalog and Routing
    • ALL
    • CAR Team 2024-04-01, CAR Team 2024-04-15, CAR Team 2024-04-29, CAR Team 2024-05-13, CAR Team 2024-05-27, CAR Team 2024-06-10, CAR Team 2025-03-03, CAR Team 2025-03-17, CAR Team 2025-03-31
    • 111
    • 1
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      Sample scenario for repro

      In a n-sharded cluster, an empty collection targeted with a createCollection({key: hashed}) should produce a routing table with the following chunk distribution:

      • if gOneChunkPerShardEmptyCollectionWithHashedShardKey is enabled (>= 7.2), n chunks and 1 chunk per shard
      • if gOneChunkPerShardEmptyCollectionWithHashedShardKey is not enabled (<7.2), 2*n chunks and 2 chunks per shard

      The logic is nevertheless flawed: the feature flag is queried multiple times during the generation of the routing table - and its value may be unstable across reads. As a consequence of this, we might end up in a state where shardCollection generates n chunks (feature flag on) but only distributes them across n/2 shards (feature flag off) when the DDL is executed concurrently with a FCV downgrade.

            Assignee:
            Allison Easton
            Reporter:
            Yuhong Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: