diff options
author | William Schultz <william.schultz@mongodb.com> | 2019-07-23 17:05:12 -0400 |
---|---|---|
committer | William Schultz <william.schultz@mongodb.com> | 2019-07-23 17:06:54 -0400 |
commit | 7d687264de65258764dca70ce46754c4765912ce (patch) | |
tree | 411231a0578fc382e99b4949f0b0f3ec3155493e /src/mongo/db/repl | |
parent | d7154f5b3ca43866a35c14f500f6ae4723c48c20 (diff) | |
download | mongo-7d687264de65258764dca70ce46754c4765912ce.tar.gz |
SERVER-42251 Timestamp multikey writes with the prepare timestamp during replication recovery
Now that we execute multikey catalog updates in a side transaction, we need to give them some suitable timestamp. In normal replication, we can grab the latest value of the LogicalClock. In startup recovery, though, we may replay a prepared transaction that does a multikey write, but the LogicalClock may not have been initialized yet. Thus, we use the prepare timestamp of the transaction for the multikey write, since that timestamp is guaranteed to be less than or equal to the commit timestamp of the transaction.
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r-- | src/mongo/db/repl/transaction_oplog_application.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/mongo/db/repl/transaction_oplog_application.cpp b/src/mongo/db/repl/transaction_oplog_application.cpp index 3445cf6a63f..c23415f61e4 100644 --- a/src/mongo/db/repl/transaction_oplog_application.cpp +++ b/src/mongo/db/repl/transaction_oplog_application.cpp @@ -350,6 +350,12 @@ Status _applyPrepareTransaction(OperationContext* opCtx, auto transaction = TransactionParticipant::get(opCtx); transaction.unstashTransactionResources(opCtx, "prepareTransaction"); + // Set this in case the application of any ops need to use the prepare timestamp of this + // transaction. It should be cleared automatically when the transaction finishes. + if (mode == repl::OplogApplication::Mode::kRecovering) { + transaction.setPrepareOpTimeForRecovery(opCtx, entry.getOpTime()); + } + auto status = _applyOperationsForTransaction(opCtx, ops, mode); fassert(31137, status); |