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

reshardCollection forceRedistribution should assert that shard key is the same

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Cluster Scalability
    • ALL
    • ClusterScalability Mar31-Apr14
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The forceRedistribution is meant for redistributing the collection to different set of shards without changing the shard key pattern. It should assert that the command is not trying to use a different shard key pattern from the original collection but instead it reshards to the new shard key provided in the command.

      Steps to reproduce:

      Shard a collection 
      sh.shardCollection("test.foo", {_id:1})
      Reshard using forceRedistribution but different shard key 
      Atlas [mongos] test> db.adminCommand({ reshardCollection: "test.foo", key: { region_id: "hashed" },numInitialChunks: 1,  forceRedistribution: true })
      {
        ok: 1,
        '$clusterTime': {
          clusterTime: Timestamp({ t: 1740780760, i: 14 }),
          signature: {
            hash: Binary.createFromBase64('ZS63GdxYKnuuF3+hOEqsh+5t9H8=', 0),
            keyId: Long('7475578754090139671')
          }
        },
        operationTime: Timestamp({ t: 1740780760, i: 14 })
      }
      
      Resharding reports success. 
      sh.status() output post resharding: 
      collections: {
            'test.foo': {
              shardKey: { region_id: 'hashed' },
              unique: false,
              balancing: true,
              chunkMetadata: [ { shard: 'atlas-gsohzn-shard-0', nChunks: 1 } ],
              chunks: [
                { min: { region_id: MinKey() }, max: { region_id: MaxKey() }, 'on shard': 'atlas-gsohzn-shard-0', 'last modified': Timestamp({ t: 1, i: 4 }) }
              ],
              tags: [
                {
                  tag: 'NewZone',
                  min: { region_id: MinKey() },
                  max: { region_id: MaxKey() }
                }
              ]
            }
      
      

            Assignee:
            janna.golden@mongodb.com Janna Golden
            Reporter:
            randolph@mongodb.com Randolph Tan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              None
              None
              None
              None