diff options
author | William Schultz <william.schultz@mongodb.com> | 2017-08-08 16:31:52 -0400 |
---|---|---|
committer | William Schultz <william.schultz@mongodb.com> | 2017-08-08 22:39:29 -0400 |
commit | c7661b14867cd058e1a67986b8e05a7020fc0a5e (patch) | |
tree | cc2f34786a5492b038456bfc34fce859dbb028c1 /src/mongo/db/repl/replication_coordinator_impl.h | |
parent | b0f8d105349d9d6df874ed7f566a552dbd98a1ab (diff) | |
download | mongo-c7661b14867cd058e1a67986b8e05a7020fc0a5e.tar.gz |
SERVER-29891 Call setStableTimestamp() when commit point or last applied optime changes
Diffstat (limited to 'src/mongo/db/repl/replication_coordinator_impl.h')
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl.h b/src/mongo/db/repl/replication_coordinator_impl.h index cb30bd1164b..55a5aa80d2e 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.h +++ b/src/mongo/db/repl/replication_coordinator_impl.h @@ -378,6 +378,15 @@ public: Status setLastDurableOptime_forTest(long long cfgVer, long long memberId, const OpTime& opTime); /** + * Simple test wrappers that expose private methods. + */ + boost::optional<Timestamp> calculateStableTimestamp_forTest( + const std::set<Timestamp>& candidates, const Timestamp& commitPoint); + void cleanupStableTimestampCandidates_forTest(std::set<Timestamp>* candidates, + Timestamp stableTimestamp); + std::set<Timestamp> getStableTimestampCandidates_forTest(); + + /** * Non-blocking version of updateTerm. * Returns event handle that we can use to wait for the operation to complete. * When the operation is complete (waitForEvent() returns), 'updateResult' will be set @@ -1015,6 +1024,28 @@ private: void _updateCommittedSnapshot_inlock(SnapshotInfo newCommittedSnapshot); /** + * Calculates the 'stable' replication timestamp given a set of timestamp candidates and the + * current commit point. The stable timestamp is the greatest timestamp in 'candidates' that is + * also less than or equal to 'commitPoint'. + */ + boost::optional<Timestamp> _calculateStableTimestamp(const std::set<Timestamp>& candidates, + const Timestamp& commitPoint); + + /** + * Removes any timestamps from the timestamp set 'candidates' that are less than + * 'stableTimestamp'. + */ + void _cleanupStableTimestampCandidates(std::set<Timestamp>* candidates, + Timestamp stableTimestamp); + + /** + * Calculates and sets the value of the 'stable' replication timestamp for the storage engine. + * See ReplicationCoordinatorImpl::_calculateStableTimestamp for a definition of 'stable', in + * this context. + */ + void _setStableTimestampForStorage_inlock(); + + /** * Drops all snapshots and clears the "committed" snapshot. */ void _dropAllSnapshots_inlock(); @@ -1280,6 +1311,12 @@ private: // When engaged, this must be <= _lastCommittedOpTime and < _uncommittedSnapshots.front(). boost::optional<SnapshotInfo> _currentCommittedSnapshot; // (M) + // A set of timestamps that are used for computing the replication system's current 'stable' + // timestamp. Every time a node's applied optime is updated, it will be added to this set. + // Timestamps that are older than the current stable timestamp should get removed from this set. + // This set should also be cleared if a rollback occurs. + std::set<Timestamp> _stableTimestampCandidates; // (M) + // Used to signal threads that are waiting for new committed snapshots. stdx::condition_variable _currentCommittedSnapshotCond; // (M) |