From 00635530f8dd4d98d765de4c215a495c49036d16 Mon Sep 17 00:00:00 2001 From: Matthew Russotto Date: Wed, 10 May 2023 13:38:39 -0400 Subject: SERVER-76987 Make oplog notification robust to step-up --- src/mongo/db/repl/replication_coordinator_external_state_impl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp index 7c7640c7be5..ea28a21a1f3 100644 --- a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp @@ -516,6 +516,10 @@ OpTime ReplicationCoordinatorExternalStateImpl::onTransitionToPrimary(OperationC << ReplicationCoordinator::newPrimaryMsg)); wuow.commit(); }); + // As far as the storage system is concerned, we're still secondary here, and will be until we + // change readWriteAbility. So new and resumed lock-free reads will read from lastApplied. We + // just advanced lastApplied by writing the no-op, so we need to signal oplog waiters. + signalOplogWaiters(); const auto loadLastOpTimeAndWallTimeResult = loadLastOpTimeAndWallTime(opCtx); fassert(28665, loadLastOpTimeAndWallTimeResult); auto opTimeToReturn = loadLastOpTimeAndWallTimeResult.getValue().opTime; -- cgit v1.2.1