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

checkShardingIndex command must throw InvalidOptions when no suitable index is found

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0, 8.0.0-rc2, 7.0.10, 7.3.3
    • Affects Version/s: 6.0.14, 5.0.26, 7.0.8, 8.1.0-rc0, 8.0.0-rc1
    • Component/s: None
    • Labels:
      None
    • Catalog and Routing
    • Fully Compatible
    • v8.0, v7.3, v7.0, v6.0, v5.0
    • CAR Team 2024-04-15
    • 152
    • 1

      When any error happens while validating the shard key index as part of shardCollection,  the error code is replaced with InvalidOptions and the original error message is kept. Looking at comments in that file, it seems that was done because shardCollection callers might catch InvalidOptions to understand whether there is not a proper shard key index.

      It's wrong to blindly transform any error to InvalidOptions because the checkShardingIndex command may fail due to reasons unrelated with the shard key index (e.g. operation interrupted during stepdown).

      Solution to fix this incorrect behavior:

      1. When no suitable index has been found, throw InvalidOptions in the command rather than returning an error message without specifying an error code.
      2. Do not transform the original error on the caller side

            Assignee:
            silvia.surroca@mongodb.com Silvia Surroca
            Reporter:
            pierlauro.sciarelli@mongodb.com Pierlauro Sciarelli
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: