diff options
author | Jason Zhang <jason.zhang@mongodb.com> | 2023-02-14 21:06:25 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-02-15 01:59:50 +0000 |
commit | 77c03f9e26931596059122c251bf875c190123e3 (patch) | |
tree | aca2fe4ffbafb1add38f557f24e4e8e8c0d71e80 /src/mongo/db | |
parent | d1fbeed2f867f9c51e6f4e0c3739fcd771567fb2 (diff) | |
download | mongo-77c03f9e26931596059122c251bf875c190123e3.tar.gz |
SERVER-70581 Handle WCOS for update and findAndModify if replacement document changes data placement
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/commands/run_aggregate.cpp | 10 | ||||
-rw-r--r-- | src/mongo/db/exec/update_stage.cpp | 1 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/mongo/db/commands/run_aggregate.cpp b/src/mongo/db/commands/run_aggregate.cpp index 9b5e718643c..b708a595391 100644 --- a/src/mongo/db/commands/run_aggregate.cpp +++ b/src/mongo/db/commands/run_aggregate.cpp @@ -677,10 +677,14 @@ Status runAggregate(OperationContext* opCtx, // If we are running a retryable write without shard key, check if the write was applied on this // shard, and if so, return early with an empty cursor with $_wasStatementExecuted - // set to true. + // set to true. The isRetryableWrite() check here is to check that the client executed write was + // a retryable write (which would've spawned an internal session for a retryable write to + // execute the two phase write without shard key protocol), otherwise we skip the retryable + // write check. auto isClusterQueryWithoutShardKeyCmd = request.getIsClusterQueryWithoutShardKeyCmd(); - auto stmtId = request.getStmtId(); - if (isClusterQueryWithoutShardKeyCmd && stmtId) { + if (opCtx->isRetryableWrite() && isClusterQueryWithoutShardKeyCmd) { + auto stmtId = request.getStmtId(); + tassert(7058100, "StmtId must be set for a retryable write without shard key", stmtId); if (TransactionParticipant::get(opCtx).checkStatementExecuted(opCtx, *stmtId)) { CursorResponseBuilder::Options options; options.isInitialResponse = true; diff --git a/src/mongo/db/exec/update_stage.cpp b/src/mongo/db/exec/update_stage.cpp index e265f0cdda1..95dd0a4d8eb 100644 --- a/src/mongo/db/exec/update_stage.cpp +++ b/src/mongo/db/exec/update_stage.cpp @@ -646,6 +646,7 @@ void UpdateStage::_checkRestrictionsOnUpdatingShardKeyAreNotViolated( serverGlobalParams.featureCompatibility) && sentShardVersion && !ShardVersion::isIgnoredVersion(*sentShardVersion); + // TODO: SERVER-73689 Fix shard key update check in update_stage.cpp to exclude _id queries. uassert(31025, "Shard key update is not allowed without specifying the full shard key in the " "query", |