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

shardCollection with hashed key does not randomly distribute chunks across the cluster

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.0.0-rc0
    • Affects Version/s: 6.0.0, 6.2.0-rc5
    • Component/s: None
    • Sharding EMEA
    • Fully Compatible
    • ALL
    • Sharding EMEA 2023-02-20, Sharding EMEA 2023-03-06
    • 0

      When shardCollection is invoked on an empty collection specifying a hashed key, the DDL will perform an optimisation: it will split its key space in a number of chunks (using the numInitialChunks parameter) and then distribute them across different shards; by this way, the collection will be added to the sharding catalog as already balanced.

      The distribution is not random: instead, chunks will be assigned to shards following the alphabetical order of shard IDs (except for the primary shard, that is assured to always receive at least one chunk).

      Such strategy may lead to a state of data imbalance at cluster level when:

      • there is a high number of empty collections being sharded with a hashed key
      • the value of numInitialChunks is lower than the number of shards in the cluster.

      One action to mitigate this effect is to shuffle the list of shard IDs instead of alphabetically sort it.

            Assignee:
            jordi.serra-torrens@mongodb.com Jordi Serra Torrens
            Reporter:
            paolo.polato@mongodb.com Paolo Polato
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: