diff options
author | Vesselina Ratcheva <vesselina.ratcheva@10gen.com> | 2019-06-12 11:47:12 -0400 |
---|---|---|
committer | Vesselina Ratcheva <vesselina.ratcheva@10gen.com> | 2019-07-03 14:33:37 -0400 |
commit | 3ed072af4e98b34189b29a4c86287c8d9c72b11a (patch) | |
tree | ac00f9aa614c1afd02350978c8b92c6b12a48d7d /src/mongo/db/repl/oplog.cpp | |
parent | 42eb2a542f26756134bd617373aa6ef87828b85a (diff) | |
download | mongo-3ed072af4e98b34189b29a4c86287c8d9c72b11a.tar.gz |
Add support for 'recoverFromOplogAsStandalone' with prepared transactions
(cherry picked from commit fd8538074a35666a8f18f54ffae798095cbc43f9)
Diffstat (limited to 'src/mongo/db/repl/oplog.cpp')
-rw-r--r-- | src/mongo/db/repl/oplog.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index 1335c308b85..d9fc1390de3 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -1417,26 +1417,30 @@ Status applyOperation_inlock(OperationContext* opCtx, // We do not assign timestamps on replicated writes since they will get their oplog // timestamp once they are logged. return false; + } else if (haveWrappingWriteUnitOfWork) { + // We do not assign timestamps to non-replicated writes that have a wrapping + // WriteUnitOfWork, as they will get the timestamp on that WUOW. + // The typical usage of this is for operations inside of atomic 'applyOps' commands + // being applied on a secondary. They will get the timestamp of the outer 'applyOps' + // oplog entry in their wrapper WUOW. + // We also use a WUOW for replaying a prepared transaction when we encounter its + // corresponding commitTransaction entry during recovery. We set the timestamp on the + // WUOW to be the commit timestamp. + return false; } else { switch (replMode) { case ReplicationCoordinator::modeReplSet: { - if (haveWrappingWriteUnitOfWork) { - // We do not assign timestamps to non-replicated writes that have a wrapping - // WUOW. These must be operations inside of atomic 'applyOps' commands being - // applied on a secondary. They will get the timestamp of the outer - // 'applyOps' oplog entry in their wrapper WUOW. - return false; - } - break; + // We typically timestamp these writes, unless they are in a WUOW. + return true; } case ReplicationCoordinator::modeNone: { // Only assign timestamps on standalones during replication recovery when - // started with 'recoverFromOplogAsStandalone'. + // started with the 'recoverFromOplogAsStandalone' flag. return mode == OplogApplication::Mode::kRecovering; } } } - return true; + MONGO_UNREACHABLE; }(); invariant(!assignOperationTimestamp || !fieldTs.eoo(), str::stream() << "Oplog entry did not have 'ts' field when expected: " << redact(op)); |