allowChunkOperations may remain to false when a shard receives its first chunk

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Catalog and Routing
    • ALL
    • Hide
      import {ShardingTest} from "jstests/libs/shardingtest.js";const st = new ShardingTest({
          shards: 2,
          rs: {nodes: 3},
          setParameter: {
              featureFlagAuthoritativeShardsDDL: true,
              featureFlagAuthoritativeShardsCRUD: true,
          },
      });const shard0Name = st.shard0.shardName;
      const shard1Name = st.shard1.shardName;const dbName = "testdb";
      const ns = dbName + ".coll";assert.commandWorked(st.s.adminCommand({enableSharding: dbName, primaryShard: shard1Name}));
      assert.commandWorked(st.s.adminCommand({shardCollection: ns, key: {a: 1}}));
      assert.commandWorked(st.s.getCollection(ns).createIndex({a: 1, b: 1}));// Run any DDL operation to broadcast setAllowChunkOperations to stop/resume chunk operations
      // At this time, shard0 owns no chunks, so it should end up with a false value in allowChunkOperations
      assert.commandWorked(st.s.adminCommand({refineCollectionShardKey: ns, key: {a: 1, b: 1}}));// Force a stepdown-stepup to call _recoverAllowChunkOperations on shard0
      st.rs0.stepUp(st.rs0.getSecondary());// Move the fist chunk to shard0
      assert.commandWorked(st.s.adminCommand({moveRange: ns, min: {a: 0, b:0}, max: {a:10, b:0}, toShard: shard0Name}));// A chunk operation on shard0 will be rejected because allowChunkOperations is false
      assert.commandFailedWithCode(st.s.adminCommand({split: ns, middle: {a:5,b:0}}),ErrorCodes.ConflictingOperationInProgress);st.stop(); 
      Show
      import {ShardingTest} from "jstests/libs/shardingtest.js" ; const st = new ShardingTest({     shards: 2,     rs: {nodes: 3},     setParameter: {         featureFlagAuthoritativeShardsDDL: true ,         featureFlagAuthoritativeShardsCRUD: true ,     }, }); const shard0Name = st.shard0.shardName; const shard1Name = st.shard1.shardName; const dbName = "testdb" ; const ns = dbName + ".coll" ; assert .commandWorked(st.s.adminCommand({enableSharding: dbName, primaryShard: shard1Name})); assert .commandWorked(st.s.adminCommand({shardCollection: ns, key: {a: 1}})); assert .commandWorked(st.s.getCollection(ns).createIndex({a: 1, b: 1})); // Run any DDL operation to broadcast setAllowChunkOperations to stop/resume chunk operations // At this time, shard0 owns no chunks, so it should end up with a false value in allowChunkOperations assert .commandWorked(st.s.adminCommand({refineCollectionShardKey: ns, key: {a: 1, b: 1}})); // Force a stepdown-stepup to call _recoverAllowChunkOperations on shard0 st.rs0.stepUp(st.rs0.getSecondary()); // Move the fist chunk to shard0 assert .commandWorked(st.s.adminCommand({moveRange: ns, min: {a: 0, b:0}, max: {a:10, b:0}, toShard: shard0Name})); // A chunk operation on shard0 will be rejected because allowChunkOperations is false assert .commandFailedWithCode(st.s.adminCommand({split: ns, middle: {a:5,b:0}}),ErrorCodes.ConflictingOperationInProgress);st.stop();
    • CAR Team 2026-06-22
    • 🟥 DDL
    • None
    • None
    • None
    • None
    • None
    • None

      When a DDL operation needs to stop migrations, it sends a setAllowChunkOperations command to every shard at the beginning of the operation to disable migrations, and sends the same command again at the end to re-enable them.

      For a single setAllowChunkOperations command, the behavior is as follows:

      • (A) If the CSR is authoritative and the current shard does not own any chunks, do nothing.
      • (B) If the CSR is authoritative and the current shard owns chunks, update both the durable shard catalog and the CSR with the new allowChunkOperations value.
      • (C) If the CSR is non-authoritative, installs the CSR only if the shard owns chunks.

      The problem is that in step (C) the CSR is incorrectly being installed on secondaries regardless of whether the shard owns chunks, meaning that if it doesn't own chunk it's allowChunkOperations flag will remain as false.

            Assignee:
            Aitor Esteve Alvarado
            Reporter:
            Silvia Surroca
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: