The check for whether the shard key is being modified in a multi=true update happens after the check for whether the shard owns the document being updated has said it's fine to proceed with the update. We should instead disallow any attempts to change the shard key in multi=true updates.
// If the shard key fields remain unchanged by this update or if this document is an orphan and // so does not belong to this shard, we can skip the rest of the checks. >if ((newShardKey.woCompare(oldShardKey) == 0) || !metadata->keyBelongsToMe(oldShardKey)) { return false; } ... // We do not allow updates to the shard key when 'multi' is true. uassert(ErrorCodes::InvalidOptions, "Multi-update operations are not allowed when updating the shard key field.", !_params.request->isMulti());
- is related to
-
SERVER-39780 Throw WouldChangeOwningShard exception if write will cause document to change shards
- Closed
-
SERVER-47105 Make update stage use OwnershipFilter instead of CollectionDescription
- Closed