summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/oplog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/repl/oplog.cpp')
-rw-r--r--src/mongo/db/repl/oplog.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index e793ab4a6f4..6e083990f4e 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -1144,7 +1144,7 @@ Status applyOperation_inlock(OperationContext* opCtx,
// the individual operations will not contain a `ts` field. The caller is responsible for
// setting the timestamp before committing. Assigning a competing timestamp in this
// codepath would break that atomicity. Sharding is a consumer of this use-case.
- const bool assignOperationTimestamp = [opCtx, haveWrappingWriteUnitOfWork] {
+ const bool assignOperationTimestamp = [opCtx, haveWrappingWriteUnitOfWork, mode] {
const auto replMode = ReplicationCoordinator::get(opCtx)->getReplicationMode();
if (opCtx->writesAreReplicated()) {
// We do not assign timestamps on replicated writes since they will get their oplog
@@ -1163,8 +1163,9 @@ Status applyOperation_inlock(OperationContext* opCtx,
break;
}
case ReplicationCoordinator::modeNone: {
- // We do not assign timestamps on standalones.
- return false;
+ // Only assign timestamps on standalones during replication recovery when
+ // started with 'recoverFromOplogAsStandalone'.
+ return mode == OplogApplication::Mode::kRecovering;
}
}
}
@@ -1553,7 +1554,7 @@ Status applyCommand_inlock(OperationContext* opCtx,
}
}
- const bool assignCommandTimestamp = [opCtx] {
+ const bool assignCommandTimestamp = [opCtx, mode] {
const auto replMode = ReplicationCoordinator::get(opCtx)->getReplicationMode();
if (opCtx->writesAreReplicated()) {
// We do not assign timestamps on replicated writes since they will get their oplog
@@ -1570,8 +1571,9 @@ Status applyCommand_inlock(OperationContext* opCtx,
return true;
}
case ReplicationCoordinator::modeNone: {
- // We do not assign timestamps on standalones.
- return false;
+ // Only assign timestamps on standalones during replication recovery when
+ // started with 'recoverFromOplogAsStandalone'.
+ return mode == OplogApplication::Mode::kRecovering;
}
}
MONGO_UNREACHABLE;