diff options
author | Benety Goh <benety@mongodb.com> | 2019-08-14 15:06:25 -0400 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2019-08-14 15:06:25 -0400 |
commit | 7fbb8c5c17f457b8c28ecfa03b4083ce9fe0e8d9 (patch) | |
tree | 27c1133fba8c148781542c6f412be6b45c090089 | |
parent | 667d8fae4a1a06ede9af584857e6f1230650b134 (diff) | |
download | mongo-7fbb8c5c17f457b8c28ecfa03b4083ce9fe0e8d9.tar.gz |
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.
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
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 |