summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl
diff options
context:
space:
mode:
authorPavithra Vetriselvan <pavithra.vetriselvan@mongodb.com>2020-01-23 20:30:37 +0000
committerevergreen <evergreen@mongodb.com>2020-01-23 20:30:37 +0000
commitb5070e639428cfcaf6dcb616dc171bf36e45c311 (patch)
tree69189e2718d7e068a33f20df2a0ee39927d8610a /src/mongo/db/repl
parent822d13b197ea8bf4e8569f7fc35e7ba871c7424b (diff)
downloadmongo-b5070e639428cfcaf6dcb616dc171bf36e45c311.tar.gz
SERVER-45716 protect call to getTerm() with mutex in replSetReconfig command
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index d486e86fdea..5254f100227 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -2742,6 +2742,7 @@ Status ReplicationCoordinatorImpl::processReplSetReconfig(OperationContext* opCt
makeGuard([&] { lockAndCall(&lk, [=] { _setConfigState_inlock(kConfigSteady); }); });
ReplSetConfig oldConfig = _rsConfig;
+ auto topCoordTerm = _topCoord->getTerm();
lk.unlock();
ReplSetConfig newConfig;
@@ -2755,8 +2756,7 @@ Status ReplicationCoordinatorImpl::processReplSetReconfig(OperationContext* opCt
// When initializing a new config through the replSetReconfig command, ignore the term
// field passed in through its args. Instead, use this node's term.
- Status status =
- newConfig.initialize(newConfigObj, _topCoord->getTerm(), oldConfig.getReplicaSetId());
+ Status status = newConfig.initialize(newConfigObj, topCoordTerm, oldConfig.getReplicaSetId());
if (!status.isOK()) {
error() << "replSetReconfig got " << status << " while parsing " << newConfigObj;
return Status(ErrorCodes::InvalidReplicaSetConfig, status.reason());