From 302a4f91a54a77221f7408b95fcbb988a9366d03 Mon Sep 17 00:00:00 2001 From: Vesselina Ratcheva Date: Thu, 7 Feb 2019 18:15:44 -0500 Subject: SERVER-39139 Make canAcceptWritesFor, canAcceptWritesForDatabase and canServeReadsFor check RSTL --- src/mongo/db/repl/replication_coordinator.h | 4 ++-- src/mongo/db/repl/replication_coordinator_impl.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mongo/db/repl/replication_coordinator.h b/src/mongo/db/repl/replication_coordinator.h index 8d109bf4be9..b61b2e71495 100644 --- a/src/mongo/db/repl/replication_coordinator.h +++ b/src/mongo/db/repl/replication_coordinator.h @@ -214,8 +214,8 @@ public: * will not be able to receive writes to a database other than local (it will not be * treated as standalone node). * - * NOTE: This function can only be meaningfully called while the caller holds the global - * lock in some mode other than MODE_NONE. + * NOTE: This function can only be meaningfully called while the caller holds the + * ReplicationStateTransitionLock in some mode other than MODE_NONE. */ virtual bool canAcceptWritesForDatabase(OperationContext* opCtx, StringData dbName) = 0; diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index f003bfdba66..3becf53450a 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -2050,8 +2050,8 @@ bool ReplicationCoordinatorImpl::isMasterForReportingPurposes() { bool ReplicationCoordinatorImpl::canAcceptWritesForDatabase(OperationContext* opCtx, StringData dbName) { - // The answer isn't meaningful unless we hold the global lock. - invariant(opCtx->lockState()->isLocked()); + // The answer isn't meaningful unless we hold the ReplicationStateTransitionLock. + invariant(opCtx->lockState()->isRSTLLocked()); return canAcceptWritesForDatabase_UNSAFE(opCtx, dbName); } @@ -2073,7 +2073,7 @@ bool ReplicationCoordinatorImpl::canAcceptWritesForDatabase_UNSAFE(OperationCont bool ReplicationCoordinatorImpl::canAcceptWritesFor(OperationContext* opCtx, const NamespaceString& ns) { - invariant(opCtx->lockState()->isLocked()); + invariant(opCtx->lockState()->isRSTLLocked()); return canAcceptWritesFor_UNSAFE(opCtx, ns); } @@ -2109,7 +2109,7 @@ bool ReplicationCoordinatorImpl::canAcceptWritesFor_UNSAFE(OperationContext* opC Status ReplicationCoordinatorImpl::checkCanServeReadsFor(OperationContext* opCtx, const NamespaceString& ns, bool slaveOk) { - invariant(opCtx->lockState()->isLocked()); + invariant(opCtx->lockState()->isRSTLLocked()); return checkCanServeReadsFor_UNSAFE(opCtx, ns, slaveOk); } -- cgit v1.2.1