diff options
author | Vesselina Ratcheva <vesselina.ratcheva@10gen.com> | 2018-04-03 10:32:25 -0400 |
---|---|---|
committer | Vesselina Ratcheva <vesselina.ratcheva@10gen.com> | 2018-04-14 10:11:42 -0400 |
commit | f7593edc6c1dfa32077dee85b66255086334b8f9 (patch) | |
tree | 5800294718bda6a196b2c518431d2a273970805b /src/mongo/db/repl/rollback_impl.h | |
parent | 5bc894ea366b5b2e9c6b9ecf5a41497e4a0fd860 (diff) | |
download | mongo-f7593edc6c1dfa32077dee85b66255086334b8f9.tar.gz |
SERVER-31007 Calculate rollback time limit correctly
Diffstat (limited to 'src/mongo/db/repl/rollback_impl.h')
-rw-r--r-- | src/mongo/db/repl/rollback_impl.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/mongo/db/repl/rollback_impl.h b/src/mongo/db/repl/rollback_impl.h index 38230880d41..a94d11c93e4 100644 --- a/src/mongo/db/repl/rollback_impl.h +++ b/src/mongo/db/repl/rollback_impl.h @@ -93,6 +93,16 @@ struct RollbackStats { * The directory containing rollback data files, if any were written. */ boost::optional<std::string> rollbackDataFileDirectory; + + /** + * The last wall clock time on the branch of history being rolled back, if known. + */ + boost::optional<Date_t> lastLocalWallClockTime; + + /** + * The wall clock time at the common point, if known. + */ + boost::optional<Date_t> commonPointWallClockTime; }; /** @@ -203,6 +213,32 @@ public: } }; + class RollbackTimeLimitHolder { + public: + /** + * Returns the maximum amount of data we are willing to roll back, in seconds. + */ + unsigned long long getRollbackTimeLimit() const { + const stdx::lock_guard<stdx::mutex> lock(_rollbackTimeLimitSecsMutex); + return _rollbackTimeLimitSecs; + } + + /** + * Set a new limit on the allowed length of the rollback period. Measured in seconds. + */ + void setRollbackTimeLimit(unsigned long long newLimit) { + const stdx::lock_guard<stdx::mutex> lock(_rollbackTimeLimitSecsMutex); + _rollbackTimeLimitSecs = newLimit; + } + + private: + // Guards access to the _rollbackTimeLimitSecs member variable. + mutable stdx::mutex _rollbackTimeLimitSecsMutex; + + // We disallow rollback if the data has a larger timespan, in seconds, than this number. + unsigned long long _rollbackTimeLimitSecs = 1800; + }; + /** * Creates a RollbackImpl instance that will run the entire rollback algorithm. This is * called during steady state replication when we determine that we have to roll back after @@ -313,6 +349,12 @@ private: OperationContext* opCtx); /** + * Determines whether or not we are trying to roll back too much data. Returns an + * UnrecoverableRollbackError if we have exceeded the limit. + */ + Status _checkAgainstTimeLimit(RollBackLocalOperations::RollbackCommonPoint commonPoint); + + /** * Finds the timestamp of the record after the common point to put into the oplog truncate * after point. */ |