summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@mongodb.com>2015-02-23 16:31:40 -0500
committerSpencer T Brody <spencer@mongodb.com>2015-05-01 11:55:13 -0400
commit7993382d5c71f2bdf90cb84271f59c1d9d713789 (patch)
tree1d4789573ec14ff1ece81541cba84a200b22b82a
parent820dbbcdcd55985c31665227c1fc18d1b0457bf4 (diff)
downloadmongo-7993382d5c71f2bdf90cb84271f59c1d9d713789.tar.gz
SERVER-16849 Prevent mongos from always invalidating the user cache once, even when no user definitions are changing
(cherry picked from commit 3272a362429edbfa34fd6529e5925317f7b8a6e7)
-rw-r--r--src/mongo/db/auth/user_cache_invalidator_job.cpp18
1 files changed, 17 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 209a143b65e..8b3f2a56047 100644
--- a/src/mongo/db/auth/user_cache_invalidator_job.cpp
+++ b/src/mongo/db/auth/user_cache_invalidator_job.cpp
@@ -81,7 +81,22 @@ namespace {
UserCacheInvalidator::UserCacheInvalidator(AuthorizationManager* authzManager) :
_authzManager(authzManager) {
- _previousCacheGeneration = _authzManager->getCacheGeneration();
+
+ StatusWith<OID> currentGeneration = getCurrentCacheGeneration();
+ if (currentGeneration.isOK()) {
+ _previousCacheGeneration = currentGeneration.getValue();
+ return;
+ }
+
+ if (currentGeneration.getStatus().code() == ErrorCodes::CommandNotFound) {
+ warning() << "_getUserCacheGeneration command not found while fetching initial user "
+ "cache generation from the config server(s). This most likely means you are "
+ "running an outdated version of mongod on the config servers";
+ } else {
+ warning() << "An error occurred while fetching initial user cache generation from "
+ "config servers: " << currentGeneration.getStatus();
+ }
+ _previousCacheGeneration = OID();
}
void UserCacheInvalidator::run() {
@@ -106,6 +121,7 @@ namespace {
}
// When in doubt, invalidate the cache
_authzManager->invalidateUserCache();
+ continue;
}
if (currentGeneration.getValue() != _previousCacheGeneration) {