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

Disallow sharding with wildcard shard key pattern

    • Fully Compatible
    • ALL
    • v6.3, v6.0, v5.0, v4.4, v4.2
    • Sharding NYC 2023-03-06

      Currently, the validation within the ShardKeyPattern class doesn't check that the shard key fields don't have the "$" prefix. So the shardCollection command depends on the index key pattern validation here to prevent a shard key like {"$x": 1} from being used. However, "$**" is a special field name is allowed to bypass this check.

      As a result, one can run a shardCollection command with the shard key with {"$**": 1} without getting any error. However, the resulting collection appears to have a number of unexpected behaviors. For example:

      • Running a listCollections command would fail with a BadValue error "unknown top level operator: $**. If you have a field name that starts with a '$' symbol, consider using $getField or $setField.".
      • Running a {$collStats: {}} aggregation would hit this tassert in QueryPlannerIXSelect.

            Assignee:
            cheahuychou.mao@mongodb.com Cheahuychou Mao
            Reporter:
            cheahuychou.mao@mongodb.com Cheahuychou Mao
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: