summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/run_aggregate.cpp
diff options
context:
space:
mode:
authorJason Zhang <jason.zhang@mongodb.com>2023-02-14 21:06:25 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-02-15 01:59:50 +0000
commit77c03f9e26931596059122c251bf875c190123e3 (patch)
treeaca2fe4ffbafb1add38f557f24e4e8e8c0d71e80 /src/mongo/db/commands/run_aggregate.cpp
parentd1fbeed2f867f9c51e6f4e0c3739fcd771567fb2 (diff)
downloadmongo-77c03f9e26931596059122c251bf875c190123e3.tar.gz
SERVER-70581 Handle WCOS for update and findAndModify if replacement document changes data placement
Diffstat (limited to 'src/mongo/db/commands/run_aggregate.cpp')
-rw-r--r--src/mongo/db/commands/run_aggregate.cpp10
1 files changed, 7 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;