Shard registry holds stale connection strings after removeShard

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Catalog and Routing
    • ALL
    • Hide
      1. Spawn sharded cluster with more than 1 shard
      2. Get shard map via db.adminCommand({getShardMap:1})
      3. Remove a shard
      4. Get shard map via db.adminCommand({getShardMap:1})

      The shard map at (2) and (4) is the same, even though a shard has been removed at step (3).

      Show
      Spawn sharded cluster with more than 1 shard Get shard map via db.adminCommand({getShardMap:1}) Remove a shard Get shard map via db.adminCommand({getShardMap:1}) The shard map at (2) and (4) is the same, even though a shard has been removed at step (3).
    • 🟩 Routing and Topology
    • None
    • None
    • None
    • None
    • None
    • None

      The cached connection strings are always kept when merging refresh results. This results in generating inconsistencies upon removeShard.

       

      Reproducible

      [direct: mongos] test> use config
      switched to db config
      
      [direct: mongos] config> db.shards.find()
      [
        {
          _id: 'shardA',
          host: 'shardA/localhost:1112',
          state: 1,
          topologyTime: Timestamp({ t: 1760690959, i: 12 }),
          replSetConfigVersion: Long("-1")
        },
        {
          _id: 'shardB',
          host: 'shardB/localhost:1113',
          state: 1,
          topologyTime: Timestamp({ t: 1760690959, i: 30 }),
          replSetConfigVersion: Long("-1")
        },
        {
          _id: 'shardC',
          host: 'shardC/localhost:1114',
          state: 1,
          topologyTime: Timestamp({ t: 1760690959, i: 53 }),
          replSetConfigVersion: Long("-1")
        }
      ]
      
      
      [direct: mongos] config> db.adminCommand({getShardMap:1})
      {
        map: {
          shardA: 'shardA/localhost:1112',
          shardB: 'shardB/localhost:1113',
          shardC: 'shardC/localhost:1114',
          config: 'configRepl/localhost:1115'
        },
        hosts: {
          'localhost:1113': 'shardB',
          'localhost:1112': 'shardA',
          'localhost:1114': 'shardC',
          'localhost:1115': 'config'
        },
        connStrings: {
          'shardA/localhost:1112': 'shardA',
          'shardB/localhost:1113': 'shardB',
          'shardC/localhost:1114': 'shardC',
          'configRepl/localhost:1115': 'config'
        },
        ok: 1,
        '$clusterTime': {
          clusterTime: Timestamp({ t: 1760690998, i: 1 }),
          signature: {
            hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0),
            keyId: Long("0")
          }
        },
        operationTime: Timestamp({ t: 1760690998, i: 1 })
      }
      
      [direct: mongos] config> db.adminCommand({removeShard:'shardC'})
      {
        msg: 'draining started successfully',
        state: 'started',
        shard: 'shardC',
        note: 'you need to drop or movePrimary these databases',
        dbsToMove: [],
        ok: 1,
        '$clusterTime': {
          clusterTime: Timestamp({ t: 1760691029, i: 2 }),
          signature: {
            hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0),
            keyId: Long("0")
          }
        },
        operationTime: Timestamp({ t: 1760691029, i: 2 })
      }
      
      [direct: mongos] config> db.adminCommand({removeShard:'shardC'})
      {
        msg: 'removeshard completed successfully',
        state: 'completed',
        shard: 'shardC',
        ok: 1,
        '$clusterTime': {
          clusterTime: Timestamp({ t: 1760691030, i: 17 }),
          signature: {
            hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0),
            keyId: Long("0")
          }
        },
        operationTime: Timestamp({ t: 1760691030, i: 17 })
      }
      
      
      [direct: mongos] config> db.adminCommand({getShardMap:1})
      {
        map: {
          shardA: 'shardA/localhost:1112',
          shardB: 'shardB/localhost:1113',
          config: 'configRepl/localhost:1115'
        },
        hosts: {
          'localhost:1114': 'shardC',
          'localhost:1112': 'shardA',
          'localhost:1113': 'shardB',
          'localhost:1115': 'config'
        },
        connStrings: {
          'shardA/localhost:1112': 'shardA',
          'shardB/localhost:1113': 'shardB',
          'shardC/localhost:1114': 'shardC',
          'configRepl/localhost:1115': 'config'
        },
        ok: 1,
        '$clusterTime': {
          clusterTime: Timestamp({ t: 1760691032, i: 1 }),
          signature: {
            hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0),
            keyId: Long("0")
          }
        },
        operationTime: Timestamp({ t: 1760691032, i: 1 })
      }
      
      
      
      [direct: mongos] config> db.shards.find()
      [
        {
          _id: 'shardA',
          host: 'shardA/localhost:1112',
          state: 1,
          topologyTime: Timestamp({ t: 1760691030, i: 8 }),
          replSetConfigVersion: Long("-1")
        },
        {
          _id: 'shardB',
          host: 'shardB/localhost:1113',
          state: 1,
          topologyTime: Timestamp({ t: 1760690959, i: 30 }),
          replSetConfigVersion: Long("-1")
        }
      ]
      
      

            Assignee:
            Unassigned
            Reporter:
            Pierlauro Sciarelli
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: