summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/sync_tail.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/repl/sync_tail.cpp')
-rw-r--r--src/mongo/db/repl/sync_tail.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp
index 6203d6f37f3..2f3269450c0 100644
--- a/src/mongo/db/repl/sync_tail.cpp
+++ b/src/mongo/db/repl/sync_tail.cpp
@@ -1150,16 +1150,19 @@ void SyncTail::_fillWriterVectors(OperationContext* opCtx,
// yet.
if (op.isPartialTransaction()) {
auto& partialTxnList = partialTxnOps[*op.getSessionId()];
- if (!partialTxnList.empty() &&
- partialTxnList.front()->getTxnNumber() != op.getTxnNumber()) {
- // TODO: When abortTransaction is implemented, this should invariant and
- // the list should be cleared on abort.
- partialTxnList.clear();
- }
+ // If this operation belongs to an existing partial transaction, partialTxnList
+ // must contain the previous operations of the transaction.
+ invariant(partialTxnList.empty() ||
+ partialTxnList.front()->getTxnNumber() == op.getTxnNumber());
partialTxnList.push_back(&op);
continue;
}
+ if (op.getCommandType() == OplogEntry::CommandType::kAbortTransaction) {
+ auto& partialTxnList = partialTxnOps[*op.getSessionId()];
+ partialTxnList.clear();
+ }
+
if (op.isCrudOpType()) {
auto collProperties = collPropertiesCache.getCollectionProperties(opCtx, hashedNs);