summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2023-01-06 15:14:59 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-01-06 16:05:12 +0000
commit7540de90fac2bb907c233d10281103fd3aa165ca (patch)
tree9ad3927defc96f6f5af2c250415a8d0d471f8487 /src/mongo
parent24d3b65af21a007a6ec617cb1fc7d77905a103d6 (diff)
downloadmongo-7540de90fac2bb907c233d10281103fd3aa165ca.tar.gz
SERVER-72584 ensure that oplog entries for partial transactions have both logical session and txn number
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/repl/oplog_applier_impl.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/mongo/db/repl/oplog_applier_impl.cpp b/src/mongo/db/repl/oplog_applier_impl.cpp
index f7f01d12988..6d4818d5ac7 100644
--- a/src/mongo/db/repl/oplog_applier_impl.cpp
+++ b/src/mongo/db/repl/oplog_applier_impl.cpp
@@ -719,6 +719,11 @@ void OplogApplierImpl::_deriveOpsAndFillWriterVectors(
// We also do this for prepare during initial sync.
if (op.isPartialTransaction() ||
(op.shouldPrepare() && getOptions().mode == OplogApplication::Mode::kInitialSync)) {
+ // applyOps entries generated by a transaction must have a sessionId and a
+ // transaction number.
+ invariant(op.getSessionId(), op.toStringForLogging());
+ invariant(op.getTxnNumber(), op.toStringForLogging());
+
auto& partialTxnList = partialTxnOps[*op.getSessionId()];
// If this operation belongs to an existing partial transaction, partialTxnList
// must contain the previous operations of the transaction.