summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/core/txns/transaction_continuing_cmds_refuse_api_params.js3
-rw-r--r--src/mongo/db/operation_context.h7
-rw-r--r--src/mongo/executor/remote_command_request.cpp3
3 files changed, 12 insertions, 1 deletions
diff --git a/jstests/core/txns/transaction_continuing_cmds_refuse_api_params.js b/jstests/core/txns/transaction_continuing_cmds_refuse_api_params.js
index 57c3e1b52c4..778b7d056d8 100644
--- a/jstests/core/txns/transaction_continuing_cmds_refuse_api_params.js
+++ b/jstests/core/txns/transaction_continuing_cmds_refuse_api_params.js
@@ -44,6 +44,9 @@ assert.commandFailedWithCode(
{insert: collName, documents: [doc], apiVersion: "1", apiDeprecationErrors: false}),
errorCode);
+// Transaction-continuing commands without API parameters are allowed.
+assert.commandWorked(sessionColl.runCommand({insert: collName, documents: [doc]}));
+
assert.commandWorked(session.abortTransaction_forTesting());
session.endSession();
})();
diff --git a/src/mongo/db/operation_context.h b/src/mongo/db/operation_context.h
index dbb21caf7d3..21c8c777cdf 100644
--- a/src/mongo/db/operation_context.h
+++ b/src/mongo/db/operation_context.h
@@ -465,6 +465,13 @@ public:
}
/**
+ * Returns whether this operation is continuing (not starting) a multi-document transaction.
+ */
+ bool isContinuingMultiDocumentTransaction() const {
+ return inMultiDocumentTransaction() && !isStartingMultiDocumentTransaction();
+ }
+
+ /**
* Sets whether this operation is starting a multi-document transaction.
*/
void setIsStartingMultiDocumentTransaction(bool isStartingMultiDocumentTransaction) {
diff --git a/src/mongo/executor/remote_command_request.cpp b/src/mongo/executor/remote_command_request.cpp
index 4c35525e6a9..8eb623cde61 100644
--- a/src/mongo/executor/remote_command_request.cpp
+++ b/src/mongo/executor/remote_command_request.cpp
@@ -87,7 +87,8 @@ RemoteCommandRequestBase::RemoteCommandRequestBase(RequestId requestId,
cmdObj = cmdObj.addField(BSON("clientOperationKey" << operationKey.get()).firstElement());
}
- if (opCtx && APIParameters::get(opCtx).getParamsPassed()) {
+ if (opCtx && APIParameters::get(opCtx).getParamsPassed() &&
+ !opCtx->isContinuingMultiDocumentTransaction()) {
BSONObjBuilder bob(std::move(cmdObj));
APIParameters::get(opCtx).appendInfo(&bob);
cmdObj = bob.obj();