diff options
Diffstat (limited to 'src/mongo/db/exec/update_stage.cpp')
-rw-r--r-- | src/mongo/db/exec/update_stage.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mongo/db/exec/update_stage.cpp b/src/mongo/db/exec/update_stage.cpp index d3bb4392c2b..c95cbeda107 100644 --- a/src/mongo/db/exec/update_stage.cpp +++ b/src/mongo/db/exec/update_stage.cpp @@ -614,8 +614,13 @@ bool UpdateStage::checkUpdateChangesShardKeyFields(const boost::optional<BSONObj } const auto& newObj = newObjCopy ? *newObjCopy : _doc.getObject(); - return wasExistingShardKeyUpdated(css, collDesc, newObj, oldObj) || - wasReshardingKeyUpdated(collDesc, newObj, oldObj); + + // It is possible that both the existing and new shard keys are being updated, so we do not want + // to short-circuit checking whether either is being modified. + const auto existingShardKeyUpdated = wasExistingShardKeyUpdated(css, collDesc, newObj, oldObj); + const auto reshardingKeyUpdated = wasReshardingKeyUpdated(collDesc, newObj, oldObj); + + return existingShardKeyUpdated || reshardingKeyUpdated; } bool UpdateStage::wasExistingShardKeyUpdated(CollectionShardingState* css, |