summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@mongodb.com>2015-02-23 16:31:40 -0500
committerRamon Fernandez <ramon@mongodb.com>2015-03-04 12:27:19 -0500
commit7a079105cb1bf18359c1f4e87ad27e502db7b54f (patch)
tree02a798b7098d95dabab686aca7f771bcd3b0bbf9 /src
parent8f6875ad4edca37187cf7febd4dc5fe7852f3812 (diff)
downloadmongo-7a079105cb1bf18359c1f4e87ad27e502db7b54f.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)
Diffstat (limited to 'src')
-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 8d9b9d7eb36..f7b9df312c4 100644
--- a/src/mongo/db/auth/user_cache_invalidator_job.cpp
+++ b/src/mongo/db/auth/user_cache_invalidator_job.cpp
@@ -113,7 +113,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() {
@@ -152,6 +167,7 @@ namespace {
}
// When in doubt, invalidate the cache
_authzManager->invalidateUserCache();
+ continue;
}
if (currentGeneration.getValue() != _previousCacheGeneration) {