From 6225672cf987f7dc72f7c2e94ee0044262110e6c Mon Sep 17 00:00:00 2001 From: William Schultz Date: Wed, 24 Jun 2020 21:36:02 -0400 Subject: [PATCH] SERVER-49006 Move initial sync oldest_timestamp advancement directly into initial sync oplog application callback --- src/mongo/db/repl/replication_coordinator_impl.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index 8551c53b5cd..5f548f0d97b 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -299,6 +299,11 @@ InitialSyncerOptions createInitialSyncerOptions( ReplicationCoordinator::DataConsistency consistency) { // Note that setting the last applied opTime forward also advances the global timestamp. replCoord->setMyLastAppliedOpTimeAndWallTimeForward(opTimeAndWallTime, consistency); + // The oplog application phase of initial sync starts timestamping writes, causing + // WiredTiger to pin this data in memory. Advancing the oldest timestamp in step with the + // last applied optime here will permit WiredTiger to evict this data as it sees fit. + replCoord->getServiceContext()->getStorageEngine()->setOldestTimestamp( + opTimeAndWallTime.opTime.getTimestamp()); }; options.resetOptimes = [replCoord]() { replCoord->resetMyLastOpTimes(); }; options.syncSourceSelector = replCoord; @@ -1440,11 +1445,6 @@ void ReplicationCoordinatorImpl::_setMyLastAppliedOpTimeAndWallTime( !serverGlobalParams.enableMajorityReadConcern) { _setStableTimestampForStorage(lk); } - } else if (_getMemberState_inlock().startup2()) { - // The oplog application phase of initial sync starts timestamping writes, causing - // WiredTiger to pin this data in memory. Advancing the oldest timestamp in step with the - // last applied optime here will permit WiredTiger to evict this data as it sees fit. - _service->getStorageEngine()->setOldestTimestamp(opTime.getTimestamp()); } }