diff options
-rw-r--r-- | src/mongo/db/keys_collection_manager.cpp | 27 | ||||
-rw-r--r-- | src/mongo/db/keys_collection_manager.h | 3 | ||||
-rw-r--r-- | src/mongo/db/logical_time_validator_test.cpp | 18 | ||||
-rw-r--r-- | src/mongo/db/repl/rs_rollback.cpp | 5 |
4 files changed, 9 insertions, 44 deletions
diff --git a/src/mongo/db/keys_collection_manager.cpp b/src/mongo/db/keys_collection_manager.cpp index c3c66b2b2c0..889b822477c 100644 --- a/src/mongo/db/keys_collection_manager.cpp +++ b/src/mongo/db/keys_collection_manager.cpp @@ -172,9 +172,6 @@ void KeysCollectionManager::enableKeyGenerator(OperationContext* opCtx, bool doE return StatusWith<KeysCollectionDocument>(keyGenerationStatus); } - // Set a small deadline so the refresh will not wait forever to satisfy readConcern. - opCtx->setDeadlineAfterNowBy(Milliseconds(500)); - // An error encountered by the keyGenerator should not prevent refreshing the cache auto cacheRefreshStatus = _keysCache.refresh(opCtx); @@ -185,11 +182,8 @@ void KeysCollectionManager::enableKeyGenerator(OperationContext* opCtx, bool doE return cacheRefreshStatus; }); } else { - _refresher.switchFunc(opCtx, [this](OperationContext* opCtx) { - // Set a small deadline so the refresh will not wait forever to satisfy readConcern. - opCtx->setDeadlineAfterNowBy(Milliseconds(500)); - return _keysCache.refresh(opCtx); - }); + _refresher.switchFunc( + opCtx, [this](OperationContext* opCtx) { return _keysCache.refresh(opCtx); }); } } @@ -201,7 +195,7 @@ void KeysCollectionManager::PeriodicRunner::refreshNow(OperationContext* opCtx) auto refreshRequest = [this]() { stdx::lock_guard<stdx::mutex> lk(_mutex); - if (_isStopping) { + if (_inShutdown) { uasserted(ErrorCodes::ShutdownInProgress, "aborting keys cache refresh because node is shutting down"); } @@ -235,7 +229,7 @@ void KeysCollectionManager::PeriodicRunner::_doPeriodicRefresh(ServiceContext* s { stdx::lock_guard<stdx::mutex> lock(_mutex); - if (_isStopping) { + if (_inShutdown) { break; } @@ -248,6 +242,7 @@ void KeysCollectionManager::PeriodicRunner::_doPeriodicRefresh(ServiceContext* s { auto opCtx = cc().makeOperationContext(); + auto latestKeyStatusWith = (*doRefresh)(opCtx.get()); if (latestKeyStatusWith.getStatus().isOK()) { errorCount = 0; @@ -290,7 +285,7 @@ void KeysCollectionManager::PeriodicRunner::_doPeriodicRefresh(ServiceContext* s _refreshRequest.reset(); } - if (_isStopping) { + if (_inShutdown) { break; } @@ -329,7 +324,7 @@ void KeysCollectionManager::PeriodicRunner::start(ServiceContext* service, Milliseconds refreshInterval) { stdx::lock_guard<stdx::mutex> lock(_mutex); invariant(!_backgroundThread.joinable()); - invariant(!_isStopping); + invariant(!_inShutdown); _backgroundThread = stdx::thread([this, service, threadName, refreshInterval] { _doPeriodicRefresh(service, threadName, refreshInterval); @@ -343,17 +338,11 @@ void KeysCollectionManager::PeriodicRunner::stop() { return; } - _isStopping = true; + _inShutdown = true; _refreshNeededCV.notify_all(); } _backgroundThread.join(); - - { - stdx::lock_guard<stdx::mutex> lock(_mutex); - invariant(!_backgroundThread.joinable()); - _isStopping = false; - } } bool KeysCollectionManager::PeriodicRunner::hasSeenKeys() { diff --git a/src/mongo/db/keys_collection_manager.h b/src/mongo/db/keys_collection_manager.h index e0138cf2e32..5826e2228ee 100644 --- a/src/mongo/db/keys_collection_manager.h +++ b/src/mongo/db/keys_collection_manager.h @@ -173,8 +173,7 @@ private: std::shared_ptr<RefreshFunc> _doRefresh; bool _hasSeenKeys = false; - // In the process of stopping this runner. - bool _isStopping = false; + bool _inShutdown = false; }; /** diff --git a/src/mongo/db/logical_time_validator_test.cpp b/src/mongo/db/logical_time_validator_test.cpp index 70cfe1a76f7..461689a61e6 100644 --- a/src/mongo/db/logical_time_validator_test.cpp +++ b/src/mongo/db/logical_time_validator_test.cpp @@ -181,23 +181,5 @@ TEST_F(LogicalTimeValidatorTest, ShouldGossipLogicalTimeIsFalseUntilKeysAreFound ASSERT_OK(validator()->validate(operationContext(), newTime)); } -TEST_F(LogicalTimeValidatorTest, CanSignTimesAfterReset) { - validator()->enableKeyGenerator(operationContext(), true); - - LogicalTime t1(Timestamp(10, 0)); - auto newTime = validator()->trySignLogicalTime(t1); - - ASSERT_EQ(t1.asTimestamp(), newTime.getTime().asTimestamp()); - ASSERT_TRUE(newTime.getProof()); - - validator()->resetKeyManagerCache(operationContext()->getServiceContext()); - - LogicalTime t2(Timestamp(20, 0)); - auto newTime2 = validator()->trySignLogicalTime(t2); - - ASSERT_EQ(t2.asTimestamp(), newTime2.getTime().asTimestamp()); - ASSERT_TRUE(newTime2.getProof()); -} - } // unnamed namespace } // namespace mongo diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp index bf993918cec..5b76eb1c42f 100644 --- a/src/mongo/db/repl/rs_rollback.cpp +++ b/src/mongo/db/repl/rs_rollback.cpp @@ -53,7 +53,6 @@ #include "mongo/db/dbhelpers.h" #include "mongo/db/exec/working_set_common.h" #include "mongo/db/logical_session_id.h" -#include "mongo/db/logical_time_validator.h" #include "mongo/db/ops/delete.h" #include "mongo/db/ops/update.h" #include "mongo/db/ops/update_lifecycle_impl.h" @@ -1422,10 +1421,6 @@ void rollback_internal::syncFixUp(OperationContext* opCtx, SessionCatalog::get(opCtx)->invalidateSessions(opCtx, boost::none); } - if (auto validator = LogicalTimeValidator::get(opCtx)) { - validator->resetKeyManagerCache(opCtx->getClient()->getServiceContext()); - } - // Reload the lastAppliedOpTime and lastDurableOpTime value in the replcoord and the // lastAppliedHash value in bgsync to reflect our new last op. The rollback common point does // not necessarily represent a consistent database state. For example, on a secondary, we may |