summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMisha Tyulenev <misha@mongodb.com>2018-05-17 10:08:04 -0400
committerMisha Tyulenev <misha@mongodb.com>2018-05-17 10:08:22 -0400
commit24a6081a3f7a0c4eaa9d765ef453bcda64f4288e (patch)
treec5362950096d9687cd31dcfed53a53ac1565942f /src
parentbeaaea83700548d6bf4f79ce9c9a6bdf5f7eb6af (diff)
downloadmongo-24a6081a3f7a0c4eaa9d765ef453bcda64f4288e.tar.gz
SERVER-35006 do not reset KeysCollectionManager
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/keys_collection_manager.cpp1
-rw-r--r--src/mongo/db/logical_time_validator.cpp11
-rw-r--r--src/mongo/db/logical_time_validator.h6
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp5
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp2
-rw-r--r--src/mongo/db/s/sharding_initialization_mongod.cpp2
6 files changed, 14 insertions, 13 deletions
diff --git a/src/mongo/db/keys_collection_manager.cpp b/src/mongo/db/keys_collection_manager.cpp
index 4f5bd5b1643..6b8703ce2a4 100644
--- a/src/mongo/db/keys_collection_manager.cpp
+++ b/src/mongo/db/keys_collection_manager.cpp
@@ -343,6 +343,7 @@ void KeysCollectionManager::PeriodicRunner::stop() {
}
_inShutdown = true;
+ _hasSeenKeys = false;
_refreshNeededCV.notify_all();
}
diff --git a/src/mongo/db/logical_time_validator.cpp b/src/mongo/db/logical_time_validator.cpp
index 0a3b2857724..f90d1d1ca2c 100644
--- a/src/mongo/db/logical_time_validator.cpp
+++ b/src/mongo/db/logical_time_validator.cpp
@@ -38,6 +38,7 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/auth/privilege.h"
#include "mongo/db/keys_collection_manager.h"
+#include "mongo/db/logical_clock.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/service_context.h"
#include "mongo/util/assert_util.h"
@@ -124,7 +125,7 @@ SignedLogicalTime LogicalTimeValidator::signLogicalTime(OperationContext* opCtx,
auto keyStatusWith = keyManager->getKeyForSigning(nullptr, newTime);
auto keyStatus = keyStatusWith.getStatus();
- while (keyStatus == ErrorCodes::KeyNotFound) {
+ while (keyStatus == ErrorCodes::KeyNotFound && LogicalClock::get(opCtx)->isEnabled()) {
keyManager->refreshNow(opCtx);
keyStatusWith = keyManager->getKeyForSigning(nullptr, newTime);
@@ -205,18 +206,18 @@ void LogicalTimeValidator::resetKeyManagerCache() {
_timeProofService.resetCache();
}
-void LogicalTimeValidator::resetKeyManager() {
+void LogicalTimeValidator::stopKeyManager() {
stdx::lock_guard<stdx::mutex> keyManagerLock(_mutexKeyManager);
if (_keyManager) {
- log() << "Resetting key manager";
+ log() << "Stopping key manager";
_keyManager->stopMonitoring();
- _keyManager.reset();
+ _keyManager->clearCache();
stdx::lock_guard<stdx::mutex> lk(_mutex);
_lastSeenValidTime = SignedLogicalTime();
_timeProofService.resetCache();
} else {
- log() << "Resetting key manager: no key manager exists.";
+ log() << "Stopping key manager: no key manager exists.";
}
}
diff --git a/src/mongo/db/logical_time_validator.h b/src/mongo/db/logical_time_validator.h
index 17ea7379d33..8c10fbd9219 100644
--- a/src/mongo/db/logical_time_validator.h
+++ b/src/mongo/db/logical_time_validator.h
@@ -102,10 +102,10 @@ public:
bool shouldGossipLogicalTime();
/**
- * Reset the key manager to prevent the former members of standalone replica set to use old
- * keys with sharded cluster.
+ * Stops the key manager and resets its state to prevent the former members of standalone
+ * replica set to use old keys with sharded cluster.
*/
- void resetKeyManager();
+ void stopKeyManager();
/**
* Reset the key manager cache of keys.
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index c7f2cc07184..88d3e717419 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -564,9 +564,8 @@ void ReplicationCoordinatorImpl::_finishLoadLocalConfig(
} else {
// The node is an arbiter hence will not need logical clock for external operations.
LogicalClock::get(getServiceContext())->disable();
- auto validator = LogicalTimeValidator::get(getServiceContext());
- if (validator) {
- validator->resetKeyManager();
+ if (auto validator = LogicalTimeValidator::get(getServiceContext())) {
+ validator->stopKeyManager();
}
}
diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
index 200d9984dd1..db261f273ac 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
@@ -533,7 +533,7 @@ void ReplicationCoordinatorImpl::_heartbeatReconfigStore(
if (isArbiter) {
LogicalClock::get(getGlobalServiceContext())->disable();
if (auto validator = LogicalTimeValidator::get(getGlobalServiceContext())) {
- validator->resetKeyManager();
+ validator->stopKeyManager();
}
}
diff --git a/src/mongo/db/s/sharding_initialization_mongod.cpp b/src/mongo/db/s/sharding_initialization_mongod.cpp
index 325ace6d4a1..a445626f3f1 100644
--- a/src/mongo/db/s/sharding_initialization_mongod.cpp
+++ b/src/mongo/db/s/sharding_initialization_mongod.cpp
@@ -120,7 +120,7 @@ Status initializeGlobalShardingStateForMongod(OperationContext* opCtx,
auto validator = LogicalTimeValidator::get(service);
if (validator) { // The keyManager may be existing if the node was a part of a standalone RS.
- validator->resetKeyManager();
+ validator->stopKeyManager();
}
globalConnPool.addHook(new ShardingConnectionHook(false, makeEgressHooksList(service)));