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

Return more useful errors when a shard key index can't be found for shardCollection/refineCollectionShardKey

    • Fully Compatible
    • v6.0, v5.0
    • Sharding 2021-10-18, Sharding 2021-11-01, Sharding 2021-11-15, Sharding 2021-11-29, Sharding 2021-12-13, Sharding 2021-12-27, Sharding 2022-01-10, Sharding 2022-01-24, Sharding 2022-02-07, Sharding 2022-02-21, Sharding 2022-03-07, Sharding NYC 2022-03-21, Sharding NYC 2022-04-04, Sharding NYC 2022-04-18, Sharding 2022-05-02, Sharding NYC 2022-05-16, Sharding NYC 2022-05-30, Sharding NYC 2022-06-13, Sharding 2022-06-27
    • 173

      When a collection is sharded or its shard key is refined, a "useful" index must exist on the collection that supports the proposed shard key (as defined in this comment). Verifying this involves both inspecting the collection's listIndexes output and running the checkShardingIndex command on a shard. An index with the shard key pattern can be invalid for several reasons (e.g. it's multikey, partial, sparse, has a collation, or is in the process of being built) but the error messages returned for many of these cases is the same, which can make diagnosing failures difficult. (Message when listIndexes finds no candidate index and message when checkShardingIndex finds no valid index.)

      Instead, the command should return more information as to why there is no valid index. In particular, the error should at least differentiate these cases:

      • No index exists with the shard key pattern as a prefix at all
      • An otherwise valid index exists, but is multikey, partial, sparse, is being built, or has a collation

            Assignee:
            israel.hsu@mongodb.com Israel Hsu
            Reporter:
            jack.mulrow@mongodb.com Jack Mulrow
            Votes:
            3 Vote for this issue
            Watchers:
            24 Start watching this issue

              Created:
              Updated:
              Resolved: