summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEsha Maharishi <esha.maharishi@mongodb.com>2018-10-12 17:59:06 -0400
committerEsha Maharishi <esha.maharishi@mongodb.com>2018-10-12 18:03:12 -0400
commit89b1e783fa3d5aac034b5af51ef6c1732bef5310 (patch)
treec431a04770381560689c5d27fa11d354397dfa16
parent684b2f3fe41ce9a841065b34c051a64a2a6fac30 (diff)
downloadmongo-89b1e783fa3d5aac034b5af51ef6c1732bef5310.tar.gz
SERVER-37621 Move logging in transaction command bodies to after checking that the command was sent with session info
-rw-r--r--src/mongo/db/commands/txn_cmds.cpp12
-rw-r--r--src/mongo/db/s/txn_two_phase_commit_cmds.cpp10
2 files changed, 11 insertions, 11 deletions
diff --git a/src/mongo/db/commands/txn_cmds.cpp b/src/mongo/db/commands/txn_cmds.cpp
index 3ca25bbd010..a7d691a1eb3 100644
--- a/src/mongo/db/commands/txn_cmds.cpp
+++ b/src/mongo/db/commands/txn_cmds.cpp
@@ -74,9 +74,6 @@ public:
const std::string& dbname,
const BSONObj& cmdObj,
BSONObjBuilder& result) override {
- LOG(3) << "Participant shard received commitTransaction for transaction with txnNumber "
- << opCtx->getTxnNumber() << " on session " << opCtx->getLogicalSessionId()->toBSON();
-
IDLParserErrorContext ctx("commitTransaction");
auto cmd = CommitTransaction::parse(ctx, cmdObj);
@@ -85,6 +82,9 @@ public:
"commitTransaction must be run within a transaction",
txnParticipant);
+ LOG(3) << "Participant shard received commitTransaction for transaction with txnNumber "
+ << opCtx->getTxnNumber() << " on session " << opCtx->getLogicalSessionId()->toBSON();
+
// commitTransaction is retryable.
if (txnParticipant->transactionIsCommitted()) {
// We set the client last op to the last optime observed by the system to ensure that
@@ -143,14 +143,14 @@ public:
const std::string& dbname,
const BSONObj& cmdObj,
BSONObjBuilder& result) override {
- LOG(3) << "Participant shard received abortTransaction for transaction with txnNumber "
- << opCtx->getTxnNumber() << " on session " << opCtx->getLogicalSessionId()->toBSON();
-
auto txnParticipant = TransactionParticipant::get(opCtx);
uassert(ErrorCodes::CommandFailed,
"abortTransaction must be run within a transaction",
txnParticipant);
+ LOG(3) << "Participant shard received abortTransaction for transaction with txnNumber "
+ << opCtx->getTxnNumber() << " on session " << opCtx->getLogicalSessionId()->toBSON();
+
uassert(ErrorCodes::NoSuchTransaction,
"Transaction isn't in progress",
txnParticipant->inMultiDocumentTransaction());
diff --git a/src/mongo/db/s/txn_two_phase_commit_cmds.cpp b/src/mongo/db/s/txn_two_phase_commit_cmds.cpp
index 118108f81c1..a7ffc761188 100644
--- a/src/mongo/db/s/txn_two_phase_commit_cmds.cpp
+++ b/src/mongo/db/s/txn_two_phase_commit_cmds.cpp
@@ -69,11 +69,6 @@ public:
using InvocationBase::InvocationBase;
Response typedRun(OperationContext* opCtx) {
- LOG(3)
- << "Participant shard received prepareTransaction for transaction with txnNumber "
- << opCtx->getTxnNumber() << " on session "
- << opCtx->getLogicalSessionId()->toBSON();
-
// In production, only config servers or initialized shard servers can participate in a
// sharded transaction. However, many test suites test the replication and storage parts
// of prepareTransaction against a standalone replica set, so allow skipping the check.
@@ -88,6 +83,11 @@ public:
"prepareTransaction must be run within a transaction",
txnParticipant);
+ LOG(3)
+ << "Participant shard received prepareTransaction for transaction with txnNumber "
+ << opCtx->getTxnNumber() << " on session "
+ << opCtx->getLogicalSessionId()->toBSON();
+
uassert(ErrorCodes::CommandNotSupported,
"'prepareTransaction' is only supported in feature compatibility version 4.2",
(serverGlobalParams.featureCompatibility.getVersion() ==