From 9c47a56c17f9c155f7794c09020893bfa80cb05d Mon Sep 17 00:00:00 2001 From: Jack Mulrow Date: Wed, 15 Mar 2017 12:13:35 -0400 Subject: SERVER-27721 Implement rate limiter check for advancing logical clocks --- src/mongo/db/logical_clock.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/mongo/db/logical_clock.h') diff --git a/src/mongo/db/logical_clock.h b/src/mongo/db/logical_clock.h index 0369eb9a641..aabe9a07c89 100644 --- a/src/mongo/db/logical_clock.h +++ b/src/mongo/db/logical_clock.h @@ -50,6 +50,9 @@ public: static LogicalClock* get(OperationContext* ctx); static void set(ServiceContext* service, std::unique_ptr logicalClock); + static constexpr Seconds kMaxAcceptableLogicalClockDrift = + Seconds(365 * 24 * 60 * 60); // 1 year + /** * Creates an instance of LogicalClock. The TimeProofService must already be fully initialized. */ @@ -100,6 +103,12 @@ private: Status _advanceClusterTime_inlock(SignedLogicalTime newTime); + /** + * Rate limiter for advancing logical time. Rejects newTime if its seconds value is more than + * kMaxAcceptableLogicalClockDrift seconds ahead of this node's wall clock. + */ + Status _passesRateLimiter_inlock(LogicalTime newTime); + ServiceContext* const _service; std::unique_ptr _timeProofService; -- cgit v1.2.1