-
Type:
Improvement
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Cluster Scalability
-
Fully Compatible
-
ClusterScalability Nov10-Nov24
-
None
-
None
-
None
-
None
-
None
-
None
-
None
rewriteCollection finds the existing shard key for the relevant collection before it locks in ReshardCollectionCoordinator, at which point no other resharding operations can happen during execution of the rewrite. This means that in a scenario such as this example:
- Collection A - shard key {x: 1}
- Start reshard collection A - shard key {x:1} -> {y: 1}
- rewriteCollection – CatalogClient -> getKeyPattern = {x: 1}
- commit reshard collection to {y: 1}
- rewriteCollection continues with shard key = {x: 1}
rewriteCollection will throw an error in the ReshardCollectionCoordinator on step 5 due to its shard key not matching the current shard key of the collection. It might be confusing to the user to get an InvalidOptions error due to options that were set internally in rewriteCollection, so we should instead add some logic to reset the shard key to the correct existing key if we reach this error point. We can check the provenance of the command if the shard keys don't match, and if it's a rewriteCollection command then set the shard key to the existing key.