From 7fbb8c5c17f457b8c28ecfa03b4083ce9fe0e8d9 Mon Sep 17 00:00:00 2001 From: Benety Goh Date: Wed, 14 Aug 2019 15:06:25 -0400 Subject: SERVER-42343 drop all snapshots on transition from a readable state to a non-readable one This avoids accumulating unnecessary historical information in the storage engine while we are in a non-readable state. --- src/mongo/db/repl/replication_coordinator_impl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index f532032a309..a1635f6b795 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -2694,6 +2694,12 @@ ReplicationCoordinatorImpl::_updateMemberStateFromTopologyCoordinator_inlock() { _externalState->forceSnapshotCreation(); } + if (!newState.readable() && _memberState.readable()) { + // Avoid accumulating history after transitioning to a non-readable state. + log() << "Dropping all snapshots on transition from " << _memberState << " to " << newState; + _dropAllSnapshots_inlock(); + } + if (newState.rollback()) { // When we start rollback, we need to drop all snapshots since we may need to create // out-of-order snapshots. This would be necessary even if the SnapshotName was completely -- cgit v1.2.1