summaryrefslogtreecommitdiff
path: root/src/mongo/db/op_observer_impl.cpp
diff options
context:
space:
mode:
authorCheahuychou Mao <mao.cheahuychou@gmail.com>2021-10-28 15:15:58 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-29 00:50:10 +0000
commitd8083ac44ef62344c778bfee6f619cb79f9433b0 (patch)
treef9ee87c0d8a978ebba20f182337dfccdb251dd51 /src/mongo/db/op_observer_impl.cpp
parent4e04c860df75edf6b8bd1de205de0f379f67ea25 (diff)
downloadmongo-d8083ac44ef62344c778bfee6f619cb79f9433b0.tar.gz
SERVER-58756 Support retrying internal transactions for retryable writes
Diffstat (limited to 'src/mongo/db/op_observer_impl.cpp')
-rw-r--r--src/mongo/db/op_observer_impl.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/mongo/db/op_observer_impl.cpp b/src/mongo/db/op_observer_impl.cpp
index 03488edae19..c3b07dba589 100644
--- a/src/mongo/db/op_observer_impl.cpp
+++ b/src/mongo/db/op_observer_impl.cpp
@@ -1399,6 +1399,9 @@ int logOplogEntriesForTransaction(OperationContext* opCtx,
}
}
+ // Stores the statement ids of all write statements in the transaction.
+ std::vector<StmtId> stmtIdsWritten;
+
// At the beginning of each loop iteration below, 'stmtsIter' will always point to the
// first statement of the sequence of remaining, unpacked transaction statements. If all
// statements have been packed, it should point to stmts.end(), which is the loop's
@@ -1407,7 +1410,6 @@ int logOplogEntriesForTransaction(OperationContext* opCtx,
while (stmtsIter != stmts->end()) {
BSONObjBuilder applyOpsBuilder;
- std::vector<StmtId> stmtIdsWritten;
auto nextStmt = packTransactionStatementsForApplyOps(
&applyOpsBuilder, &stmtIdsWritten, stmtsIter, stmts->end());
@@ -1469,8 +1471,13 @@ int logOplogEntriesForTransaction(OperationContext* opCtx,
auto txnState = isPartialTxn
? DurableTxnStateEnum::kInProgress
: (implicitPrepare ? DurableTxnStateEnum::kPrepared : DurableTxnStateEnum::kCommitted);
- prevWriteOpTime = logApplyOpsForTransaction(
- opCtx, &oplogEntry, txnState, startOpTime, std::move(stmtIdsWritten), updateTxnTable);
+ prevWriteOpTime =
+ logApplyOpsForTransaction(opCtx,
+ &oplogEntry,
+ txnState,
+ startOpTime,
+ (lastOp ? std::move(stmtIdsWritten) : std::vector<StmtId>{}),
+ updateTxnTable);
hangAfterLoggingApplyOpsForTransaction.pauseWhileSet();