diff options
author | Shreyas Kalyan <shreyas.kalyan@10gen.com> | 2020-03-31 18:58:19 -0700 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-01 23:02:46 +0000 |
commit | 54a62babcd39d7641064a516feb50171aac17ed9 (patch) | |
tree | ed7ff8be4545a63138935913397c92a6c9a6ad7a | |
parent | 346ddaba0c4a4e0f2309b139af942f2cd3026a1c (diff) | |
download | mongo-54a62babcd39d7641064a516feb50171aac17ed9.tar.gz |
SERVER-46834 Use monotonic time in UserCacheInvalidator
(cherry picked from commit c51dbb8eb4d81e6b70c542065eb66b9e36082d38)
-rw-r--r-- | src/mongo/db/auth/user_cache_invalidator_job.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/mongo/db/auth/user_cache_invalidator_job.cpp b/src/mongo/db/auth/user_cache_invalidator_job.cpp index fe23beb6b9e..a52e4c431bc 100644 --- a/src/mongo/db/auth/user_cache_invalidator_job.cpp +++ b/src/mongo/db/auth/user_cache_invalidator_job.cpp @@ -150,7 +150,10 @@ void UserCacheInvalidator::run() { Date_t sleepUntil = lastInvalidationTime + Seconds(userCacheInvalidationIntervalSecs.load()); Date_t now = Date_t::now(); - while (now < sleepUntil) { + + // The second clause in the if statement is if we've jumped back in time due to an NTP + // sync; we should always trigger a cache refresh in that case. + while (now < sleepUntil && now >= lastInvalidationTime) { MONGO_IDLE_THREAD_BLOCK; invalidationIntervalChangedCondition.wait_until(lock, sleepUntil.toSystemTimePoint()); sleepUntil = lastInvalidationTime + Seconds(userCacheInvalidationIntervalSecs.load()); |