summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2021-09-17 14:41:23 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-09-17 15:53:17 +0000
commit6adde2f790fecd9f9401c11462ba14639d02cd60 (patch)
tree3228e63fce8054bae26dbabb96c39e05f4f9a378
parent7f67f62cd9811d17997565efe154454c2838400d (diff)
downloadmongo-6adde2f790fecd9f9401c11462ba14639d02cd60.tar.gz
SERVER-57407 Avoid taking ReplicationCoordinator mutex when deciding …
-rw-r--r--src/mongo/db/vector_clock_mongod.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/mongo/db/vector_clock_mongod.cpp b/src/mongo/db/vector_clock_mongod.cpp
index 16ecec730c9..ea844e80155 100644
--- a/src/mongo/db/vector_clock_mongod.cpp
+++ b/src/mongo/db/vector_clock_mongod.cpp
@@ -69,7 +69,10 @@ private:
return !replicationCoordinator ||
(replicationCoordinator->getReplicationMode() ==
repl::ReplicationCoordinator::modeReplSet &&
- replicationCoordinator->getMemberState().readable());
+ // Check repl status without locks to prevent deadlocks. This is a best effort check
+ // as the repl state can change right after this check even when inspected under a
+ // lock or mutex.
+ replicationCoordinator->isInPrimaryOrSecondaryState_UNSAFE());
}
bool _permitRefreshDuringGossipOut() const override {