summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarolyn Duan <carolyn.duan@mongodb.com>2021-06-14 17:29:10 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-22 18:46:35 +0000
commite866ed8e645c034d773bc9de6dd4ec13ee769bea (patch)
treed1a4577986425d4c4f6caaf316400b3f086f16af
parent7d07ffc36c97d632e59c351d15610e0ff2ffab42 (diff)
downloadmongo-e866ed8e645c034d773bc9de6dd4ec13ee769bea.tar.gz
SERVER-47828 Add getConfig* methods to avoid copying ReplSetConfig
through ReplicationCoordinatorImpl::getConfig()
-rw-r--r--src/mongo/db/commands/set_feature_compatibility_version_command.cpp2
-rw-r--r--src/mongo/db/commands/shutdown_d.cpp2
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp3
-rw-r--r--src/mongo/db/repl/repl_set_commands.cpp2
-rw-r--r--src/mongo/db/repl/replication_coordinator.h70
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp61
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.h25
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp19
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp15
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_test.cpp46
-rw-r--r--src/mongo/db/repl/replication_coordinator_mock.cpp61
-rw-r--r--src/mongo/db/repl/replication_coordinator_mock.h25
-rw-r--r--src/mongo/db/repl/replication_coordinator_noop.cpp49
-rw-r--r--src/mongo/db/repl/replication_coordinator_noop.h24
-rw-r--r--src/mongo/db/repl/replication_coordinator_test_fixture.cpp2
-rw-r--r--src/mongo/db/repl/tenant_migration_donor_service.cpp4
-rw-r--r--src/mongo/db/repl/tenant_migration_util.h3
-rw-r--r--src/mongo/db/s/add_shard_util.cpp2
-rw-r--r--src/mongo/db/s/balancer/migration_manager.cpp2
-rw-r--r--src/mongo/db/s/config/configsvr_add_shard_command.cpp3
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp34
-rw-r--r--src/mongo/db/s/shard_local.cpp3
-rw-r--r--src/mongo/db/write_concern.cpp2
-rw-r--r--src/mongo/embedded/replication_coordinator_embedded.cpp49
-rw-r--r--src/mongo/embedded/replication_coordinator_embedded.h24
25 files changed, 451 insertions, 81 deletions
diff --git a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
index b9ac6d5718a..70d01d9c442 100644
--- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
+++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
@@ -146,7 +146,7 @@ void waitForCurrentConfigCommitment(OperationContext* opCtx) {
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
// Skip the waiting if the current config is from a force reconfig.
- auto oplogWait = replCoord->getConfig().getConfigTerm() != repl::OpTime::kUninitializedTerm;
+ auto oplogWait = replCoord->getConfigTerm() != repl::OpTime::kUninitializedTerm;
auto status = replCoord->awaitConfigCommitment(opCtx, oplogWait);
status.addContext("New feature compatibility version is rejected");
if (status == ErrorCodes::MaxTimeMSExpired) {
diff --git a/src/mongo/db/commands/shutdown_d.cpp b/src/mongo/db/commands/shutdown_d.cpp
index c4ac2211c9f..dad66bfcfa7 100644
--- a/src/mongo/db/commands/shutdown_d.cpp
+++ b/src/mongo/db/commands/shutdown_d.cpp
@@ -52,7 +52,7 @@ Status stepDownForShutdown(OperationContext* opCtx,
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
// If this is a single node replica set, then we don't have to wait
// for any secondaries. Ignore stepdown.
- if (replCoord->getConfig().getNumMembers() != 1) {
+ if (replCoord->getConfigNumMembers() != 1) {
try {
if (MONGO_unlikely(hangInShutdownBeforeStepdown.shouldFail())) {
LOGV2(5436600, "hangInShutdownBeforeStepdown failpoint enabled");
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp
index 467b4bc3d8e..b9f98f78632 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -433,9 +433,8 @@ bool isIndexBuildResumable(OperationContext* opCtx,
}
// Ensure that this node is a voting member in the replica set config.
- auto rsConfig = replCoord->getConfig();
auto hap = replCoord->getMyHostAndPort();
- if (auto memberConfig = rsConfig.findMemberByHostAndPort(hap)) {
+ if (auto memberConfig = replCoord->findConfigMemberByHostAndPort(hap)) {
if (!memberConfig->isVoter()) {
return false;
}
diff --git a/src/mongo/db/repl/repl_set_commands.cpp b/src/mongo/db/repl/repl_set_commands.cpp
index 20b0ae5fc35..8cbc17cb657 100644
--- a/src/mongo/db/repl/repl_set_commands.cpp
+++ b/src/mongo/db/repl/repl_set_commands.cpp
@@ -424,7 +424,7 @@ public:
// of concurrent reconfigs.
if (!parsedArgs.force) {
// Skip the waiting if the current config is from a force reconfig.
- auto oplogWait = replCoord->getConfig().getConfigTerm() != OpTime::kUninitializedTerm;
+ auto oplogWait = replCoord->getConfigTerm() != OpTime::kUninitializedTerm;
auto status = replCoord->awaitConfigCommitment(opCtx, oplogWait);
status.addContext("New config is rejected");
if (status == ErrorCodes::MaxTimeMSExpired) {
diff --git a/src/mongo/db/repl/replication_coordinator.h b/src/mongo/db/repl/replication_coordinator.h
index e4dae524dfb..23b5ce1bd48 100644
--- a/src/mongo/db/repl/replication_coordinator.h
+++ b/src/mongo/db/repl/replication_coordinator.h
@@ -44,6 +44,7 @@
#include "mongo/db/storage/storage_engine_init.h"
#include "mongo/executor/task_executor.h"
#include "mongo/rpc/topology_version_gen.h"
+#include "mongo/util/duration.h"
#include "mongo/util/net/hostandport.h"
#include "mongo/util/time_support.h"
@@ -621,10 +622,79 @@ public:
/**
* Returns a copy of the current ReplSetConfig.
+ *
+ * To avoid unnecessarily copying the ReplSetConfig through this method, please use the
+ * getConfig* methods below if you are only accessing a specific field of the ReplSetConfig,
+ * i.e. replCoord->getConfigNumMembers() instead of replCoord->getConfig().getNumMembers(). See
+ * SERVER-47828.
*/
virtual ReplSetConfig getConfig() const = 0;
/**
+ * Returns the current ReplSetConfig's connection string.
+ */
+ virtual ConnectionString getConfigConnectionString() const = 0;
+
+ /**
+ * Returns the current ReplSetConfig's election timeout period.
+ */
+ virtual Milliseconds getConfigElectionTimeoutPeriod() const = 0;
+
+ /**
+ * Returns the current ReplSetConfig's voting members.
+ */
+ virtual std::vector<MemberConfig> getConfigVotingMembers() const = 0;
+
+ /**
+ * Returns the current ReplSetConfig's term.
+ */
+ virtual std::int64_t getConfigTerm() const = 0;
+
+ /**
+ * Returns the current ReplSetConfig's version.
+ */
+ virtual std::int64_t getConfigVersion() const = 0;
+
+ /**
+ * Returns the (version, term) pair of the current ReplSetConfig.
+ */
+ virtual ConfigVersionAndTerm getConfigVersionAndTerm() const = 0;
+
+ /**
+ * Returns the number of members in the current ReplSetConfig.
+ */
+ virtual int getConfigNumMembers() const = 0;
+
+ /**
+ * Returns the amount of time to wait for a response to heartbeats sent to other
+ * nodes in the current ReplSetConfig.
+ */
+ virtual Milliseconds getConfigHeartbeatTimeoutPeriodMillis() const = 0;
+
+ /**
+ * Returns the BSON of the current ReplSetConfig.
+ */
+ virtual BSONObj getConfigBSON() const = 0;
+
+ /**
+ * Returns a pointer to the MemberConfig corresponding to the member with the given
+ * HostAndPort in the current ReplSetConfig, or NULL if there is no member with that address.
+ */
+ virtual const MemberConfig* findConfigMemberByHostAndPort(const HostAndPort& hap) const = 0;
+
+ /**
+ * Returns whether all members of the current ReplSetConfig set have hostname localhost.
+ */
+ virtual bool isConfigLocalHostAllowed() const = 0;
+
+ /**
+ * Returns the interval between the time the last heartbeat from a node was received
+ * successfully, or the time when we gave up retrying, and when the next heartbeat should be
+ * sent to a target, for the current ReplSetConfig.
+ */
+ virtual Milliseconds getConfigHeartbeatInterval() const = 0;
+
+ /**
* Handles an incoming replSetGetConfig command. Adds BSON to 'result'.
*
* If commitmentStatus is true, adds a boolean 'commitmentStatus' field to 'result' indicating
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index bb96489547b..60012c094eb 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -3041,6 +3041,67 @@ ReplSetConfig ReplicationCoordinatorImpl::getConfig() const {
return _rsConfig;
}
+ConnectionString ReplicationCoordinatorImpl::getConfigConnectionString() const {
+ stdx::lock_guard<Latch> lock(_mutex);
+ return _rsConfig.getConnectionString();
+}
+
+Milliseconds ReplicationCoordinatorImpl::getConfigElectionTimeoutPeriod() const {
+ stdx::lock_guard<Latch> lock(_mutex);
+ return _rsConfig.getElectionTimeoutPeriod();
+}
+
+std::vector<MemberConfig> ReplicationCoordinatorImpl::getConfigVotingMembers() const {
+ stdx::lock_guard<Latch> lock(_mutex);
+ return _rsConfig.votingMembers();
+}
+
+std::int64_t ReplicationCoordinatorImpl::getConfigTerm() const {
+ stdx::lock_guard<Latch> lock(_mutex);
+ return _rsConfig.getConfigTerm();
+}
+
+std::int64_t ReplicationCoordinatorImpl::getConfigVersion() const {
+ stdx::lock_guard<Latch> lock(_mutex);
+ return _rsConfig.getConfigVersion();
+}
+
+ConfigVersionAndTerm ReplicationCoordinatorImpl::getConfigVersionAndTerm() const {
+ stdx::lock_guard<Latch> lock(_mutex);
+ return _rsConfig.getConfigVersionAndTerm();
+}
+
+int ReplicationCoordinatorImpl::getConfigNumMembers() const {
+ stdx::lock_guard<Latch> lock(_mutex);
+ return _rsConfig.getNumMembers();
+}
+
+Milliseconds ReplicationCoordinatorImpl::getConfigHeartbeatTimeoutPeriodMillis() const {
+ stdx::lock_guard<Latch> lock(_mutex);
+ return _rsConfig.getHeartbeatTimeoutPeriodMillis();
+}
+
+BSONObj ReplicationCoordinatorImpl::getConfigBSON() const {
+ stdx::lock_guard<Latch> lock(_mutex);
+ return _rsConfig.toBSON();
+}
+
+const MemberConfig* ReplicationCoordinatorImpl::findConfigMemberByHostAndPort(
+ const HostAndPort& hap) const {
+ stdx::lock_guard<Latch> lock(_mutex);
+ return _rsConfig.findMemberByHostAndPort(hap);
+}
+
+bool ReplicationCoordinatorImpl::isConfigLocalHostAllowed() const {
+ stdx::lock_guard<Latch> lock(_mutex);
+ return _rsConfig.isLocalHostAllowed();
+}
+
+Milliseconds ReplicationCoordinatorImpl::getConfigHeartbeatInterval() const {
+ stdx::lock_guard<Latch> lock(_mutex);
+ return _rsConfig.getHeartbeatInterval();
+}
+
WriteConcernOptions ReplicationCoordinatorImpl::_getOplogCommitmentWriteConcern(WithLock lk) {
auto syncMode = getWriteConcernMajorityShouldJournal_inlock()
? WriteConcernOptions::SyncMode::JOURNAL
diff --git a/src/mongo/db/repl/replication_coordinator_impl.h b/src/mongo/db/repl/replication_coordinator_impl.h
index d1ea4af7680..fcd444d4c6e 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.h
+++ b/src/mongo/db/repl/replication_coordinator_impl.h
@@ -230,6 +230,31 @@ public:
virtual ReplSetConfig getConfig() const override;
+ virtual ConnectionString getConfigConnectionString() const override;
+
+ virtual Milliseconds getConfigElectionTimeoutPeriod() const override;
+
+ virtual std::vector<MemberConfig> getConfigVotingMembers() const override;
+
+ virtual std::int64_t getConfigTerm() const override;
+
+ virtual std::int64_t getConfigVersion() const override;
+
+ virtual ConfigVersionAndTerm getConfigVersionAndTerm() const override;
+
+ virtual int getConfigNumMembers() const override;
+
+ virtual Milliseconds getConfigHeartbeatTimeoutPeriodMillis() const override;
+
+ virtual BSONObj getConfigBSON() const override;
+
+ virtual const MemberConfig* findConfigMemberByHostAndPort(
+ const HostAndPort& hap) const override;
+
+ virtual bool isConfigLocalHostAllowed() const override;
+
+ virtual Milliseconds getConfigHeartbeatInterval() const override;
+
virtual void processReplSetGetConfig(BSONObjBuilder* result,
bool commitmentStatus = false,
bool includeNewlyAdded = false) override;
diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp
index a72916fbde3..1922af89a9a 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp
@@ -471,8 +471,8 @@ TEST_F(ReplCoordHBV1ReconfigTest,
getNet()->scheduleResponse(noi, getNet()->now(), makeResponseStatus(origResObj));
getNet()->runReadyNetworkOperations();
- ASSERT_EQ(getReplCoord()->getConfig().getConfigVersion(), initConfigVersion + 1);
- ASSERT_EQ(getReplCoord()->getConfig().getConfigTerm(), initConfigTerm);
+ ASSERT_EQ(getReplCoord()->getConfigVersion(), initConfigVersion + 1);
+ ASSERT_EQ(getReplCoord()->getConfigTerm(), initConfigTerm);
}
TEST_F(ReplCoordHBV1ReconfigTest,
@@ -515,7 +515,7 @@ TEST_F(ReplCoordHBV1ReconfigTest,
getNet()->scheduleResponse(noi, getNet()->now(), makeResponseStatus(origResObj));
getNet()->runReadyNetworkOperations();
- ASSERT_EQ(getReplCoord()->getConfig().getConfigTerm(), initConfigTerm + 1);
+ ASSERT_EQ(getReplCoord()->getConfigTerm(), initConfigTerm + 1);
}
TEST_F(ReplCoordHBV1ReconfigTest,
@@ -568,8 +568,8 @@ TEST_F(
getNet()->scheduleResponse(noi, getNet()->now(), makeResponseStatus(origResObj));
getNet()->runReadyNetworkOperations();
- ASSERT_EQ(getReplCoord()->getConfig().getConfigVersion(), (initConfigVersion - 1));
- ASSERT_EQ(getReplCoord()->getConfig().getConfigTerm(), (initConfigTerm + 1));
+ ASSERT_EQ(getReplCoord()->getConfigVersion(), (initConfigVersion - 1));
+ ASSERT_EQ(getReplCoord()->getConfigTerm(), (initConfigTerm + 1));
}
TEST_F(
@@ -614,8 +614,8 @@ TEST_F(
getNet()->scheduleResponse(noi, getNet()->now(), makeResponseStatus(origResObj));
getNet()->runReadyNetworkOperations();
- ASSERT_EQ(getReplCoord()->getConfig().getConfigVersion(), (initConfigVersion + 1));
- ASSERT_EQ(getReplCoord()->getConfig().getConfigTerm(), UninitializedTerm);
+ ASSERT_EQ(getReplCoord()->getConfigVersion(), (initConfigVersion + 1));
+ ASSERT_EQ(getReplCoord()->getConfigTerm(), UninitializedTerm);
}
TEST_F(ReplCoordHBV1ReconfigTest,
@@ -1527,11 +1527,10 @@ void HBStepdownAndReconfigTest::assertSteppedDown() {
void HBStepdownAndReconfigTest::assertConfigStored() {
LOGV2(463812, "Waiting for config to be stored");
// Wait for new config since it may be installed asynchronously.
- while (getReplCoord()->getConfig().getConfigVersionAndTerm() < ConfigVersionAndTerm(3, 1)) {
+ while (getReplCoord()->getConfigVersionAndTerm() < ConfigVersionAndTerm(3, 1)) {
sleepFor(Milliseconds(10));
}
- ASSERT_EQUALS(ConfigVersionAndTerm(3, 1),
- getReplCoord()->getConfig().getConfigVersionAndTerm());
+ ASSERT_EQUALS(ConfigVersionAndTerm(3, 1), getReplCoord()->getConfigVersionAndTerm());
}
TEST_F(HBStepdownAndReconfigTest, HBStepdownThenHBReconfig) {
diff --git a/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
index 194923099a6..f738cc855f0 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp
@@ -642,8 +642,7 @@ TEST_F(ReplCoordTest, OverrideReconfigBsonTermSoReconfigSucceeds) {
ASSERT_OK(status);
// After the reconfig, the config term should be 1, not 50.
- const auto config = getReplCoord()->getConfig();
- ASSERT_EQUALS(config.getConfigTerm(), 1);
+ ASSERT_EQUALS(getReplCoord()->getConfigTerm(), 1);
}
TEST_F(
@@ -1155,8 +1154,8 @@ public:
hbResp.setState(MemberState::RS_SECONDARY);
}
// Secondaries learn of the config version and term immediately.
- hbResp.setConfigVersion(getReplCoord()->getConfig().getConfigVersion());
- hbResp.setConfigTerm(getReplCoord()->getConfig().getConfigTerm());
+ hbResp.setConfigVersion(getReplCoord()->getConfigVersion());
+ hbResp.setConfigTerm(getReplCoord()->getConfigTerm());
BSONObjBuilder respObj;
hbResp.setAppliedOpTimeAndWallTime({OpTime(Timestamp(100, 1), 0), Date_t() + Seconds(100)});
hbResp.setDurableOpTimeAndWallTime({OpTime(Timestamp(100, 1), 0), Date_t() + Seconds(100)});
@@ -1228,7 +1227,7 @@ public:
Status status(ErrorCodes::InternalError, "Not Set");
args.force = false;
args.newConfigObj =
- configWithMembers(configVersion, getReplCoord()->getConfig().getConfigTerm(), members);
+ configWithMembers(configVersion, getReplCoord()->getConfigTerm(), members);
stdx::thread reconfigThread = stdx::thread(
[&] { status = getReplCoord()->processReplSetReconfig(opCtx, args, &result); });
// Satisfy quorum check with heartbeats.
@@ -1245,7 +1244,7 @@ public:
}
void replicateOpTo(int nodeId, OpTime op) {
- auto configVersion = getReplCoord()->getConfig().getConfigVersion();
+ auto configVersion = getReplCoord()->getConfigVersion();
ASSERT_OK(getReplCoord()->setLastAppliedOptime_forTest(configVersion, nodeId, op));
ASSERT_OK(getReplCoord()->setLastDurableOptime_forTest(configVersion, nodeId, op));
}
@@ -2425,7 +2424,7 @@ TEST_F(ReplCoordTest, StepUpReconfigConcurrentWithHeartbeatReconfig) {
// We should have moved to a new term in the election, and our config should have the same term.
ASSERT_EQUALS(getReplCoord()->getTerm(), 1);
- ASSERT_EQUALS(getReplCoord()->getConfig().getConfigTerm(), 1);
+ ASSERT_EQUALS(getReplCoord()->getConfigTerm(), 1);
}
TEST_F(ReplCoordTest, StepUpReconfigConcurrentWithForceHeartbeatReconfig) {
@@ -2522,7 +2521,7 @@ TEST_F(ReplCoordTest, StepUpReconfigConcurrentWithForceHeartbeatReconfig) {
// We should have moved to a new term in the election, but our config should have the term from
// the force config.
ASSERT_EQUALS(getReplCoord()->getTerm(), 1);
- ASSERT_EQUALS(getReplCoord()->getConfig().getConfigTerm(), OpTime::kUninitializedTerm);
+ ASSERT_EQUALS(getReplCoord()->getConfigTerm(), OpTime::kUninitializedTerm);
}
} // anonymous namespace
diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
index c622bc6cbdc..ce1896fe4a0 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
@@ -1497,8 +1497,7 @@ protected:
// Makes it so enough secondaries are caught up that a stepdown command can succeed.
void catchUpSecondaries(const OpTime& desiredOpTime, Date_t desiredWallTime = Date_t()) {
- auto config = getReplCoord()->getConfig();
- auto heartbeatInterval = config.getHeartbeatInterval();
+ auto heartbeatInterval = getReplCoord()->getConfigHeartbeatInterval();
if (desiredWallTime == Date_t() && !desiredOpTime.isNull()) {
desiredWallTime = Date_t() + Seconds(desiredOpTime.getSecs());
}
@@ -1606,15 +1605,13 @@ TEST_F(ReplCoordTest, UpdatePositionArgsAdvancesWallTimes) {
<< 1 << UpdatePositionArgs::kUpdateArrayFieldName
<< BSON_ARRAY(
BSON(UpdatePositionArgs::kConfigVersionFieldName
- << repl->getConfig().getConfigVersion()
- << UpdatePositionArgs::kMemberIdFieldName << 1
+ << repl->getConfigVersion() << UpdatePositionArgs::kMemberIdFieldName << 1
<< UpdatePositionArgs::kAppliedOpTimeFieldName << opTime2.asOpTime().toBSON()
<< UpdatePositionArgs::kAppliedWallTimeFieldName << memberOneAppliedWallTime
<< UpdatePositionArgs::kDurableOpTimeFieldName << opTime2.asOpTime().toBSON()
<< UpdatePositionArgs::kDurableWallTimeFieldName << memberOneDurableWallTime)
<< BSON(UpdatePositionArgs::kConfigVersionFieldName
- << repl->getConfig().getConfigVersion()
- << UpdatePositionArgs::kMemberIdFieldName << 2
+ << repl->getConfigVersion() << UpdatePositionArgs::kMemberIdFieldName << 2
<< UpdatePositionArgs::kAppliedOpTimeFieldName << opTime2.asOpTime().toBSON()
<< UpdatePositionArgs::kAppliedWallTimeFieldName << memberTwoAppliedWallTime
<< UpdatePositionArgs::kDurableOpTimeFieldName << opTime2.asOpTime().toBSON()
@@ -1891,8 +1888,7 @@ TEST_F(StepDownTest, StepDownCanCompleteBasedOnReplSetUpdatePositionAlone) {
<< 1 << UpdatePositionArgs::kUpdateArrayFieldName
<< BSON_ARRAY(
BSON(UpdatePositionArgs::kConfigVersionFieldName
- << repl->getConfig().getConfigVersion()
- << UpdatePositionArgs::kMemberIdFieldName << 1
+ << repl->getConfigVersion() << UpdatePositionArgs::kMemberIdFieldName << 1
<< UpdatePositionArgs::kAppliedOpTimeFieldName << opTime2.asOpTime().toBSON()
<< UpdatePositionArgs::kAppliedWallTimeFieldName
<< Date_t() + Seconds(opTime2.asOpTime().getSecs())
@@ -1900,8 +1896,7 @@ TEST_F(StepDownTest, StepDownCanCompleteBasedOnReplSetUpdatePositionAlone) {
<< UpdatePositionArgs::kDurableWallTimeFieldName
<< Date_t() + Seconds(opTime2.asOpTime().getSecs()))
<< BSON(UpdatePositionArgs::kConfigVersionFieldName
- << repl->getConfig().getConfigVersion()
- << UpdatePositionArgs::kMemberIdFieldName << 2
+ << repl->getConfigVersion() << UpdatePositionArgs::kMemberIdFieldName << 2
<< UpdatePositionArgs::kAppliedOpTimeFieldName << opTime1.asOpTime().toBSON()
<< UpdatePositionArgs::kAppliedWallTimeFieldName
<< Date_t() + Seconds(opTime1.asOpTime().getSecs())
@@ -2028,8 +2023,7 @@ TEST_F(StepDownTestWithUnelectableNode,
<< 1 << UpdatePositionArgs::kUpdateArrayFieldName
<< BSON_ARRAY(
BSON(UpdatePositionArgs::kConfigVersionFieldName
- << repl->getConfig().getConfigVersion()
- << UpdatePositionArgs::kMemberIdFieldName << 1
+ << repl->getConfigVersion() << UpdatePositionArgs::kMemberIdFieldName << 1
<< UpdatePositionArgs::kAppliedOpTimeFieldName << opTime2.asOpTime().toBSON()
<< UpdatePositionArgs::kAppliedWallTimeFieldName
<< Date_t() + Seconds(opTime2.asOpTime().getSecs())
@@ -2037,8 +2031,7 @@ TEST_F(StepDownTestWithUnelectableNode,
<< UpdatePositionArgs::kDurableWallTimeFieldName
<< Date_t() + Seconds(opTime2.asOpTime().getSecs()))
<< BSON(UpdatePositionArgs::kConfigVersionFieldName
- << repl->getConfig().getConfigVersion()
- << UpdatePositionArgs::kMemberIdFieldName << 2
+ << repl->getConfigVersion() << UpdatePositionArgs::kMemberIdFieldName << 2
<< UpdatePositionArgs::kAppliedOpTimeFieldName << opTime1.asOpTime().toBSON()
<< UpdatePositionArgs::kAppliedWallTimeFieldName
<< Date_t() + Seconds(opTime1.asOpTime().getSecs())
@@ -2060,8 +2053,7 @@ TEST_F(StepDownTestWithUnelectableNode,
<< 1 << UpdatePositionArgs::kUpdateArrayFieldName
<< BSON_ARRAY(
BSON(UpdatePositionArgs::kConfigVersionFieldName
- << repl->getConfig().getConfigVersion()
- << UpdatePositionArgs::kMemberIdFieldName << 1
+ << repl->getConfigVersion() << UpdatePositionArgs::kMemberIdFieldName << 1
<< UpdatePositionArgs::kAppliedOpTimeFieldName << opTime2.asOpTime().toBSON()
<< UpdatePositionArgs::kAppliedWallTimeFieldName
<< Date_t() + Seconds(opTime2.asOpTime().getSecs())
@@ -2069,8 +2061,7 @@ TEST_F(StepDownTestWithUnelectableNode,
<< UpdatePositionArgs::kDurableWallTimeFieldName
<< Date_t() + Seconds(opTime2.asOpTime().getSecs()))
<< BSON(UpdatePositionArgs::kConfigVersionFieldName
- << repl->getConfig().getConfigVersion()
- << UpdatePositionArgs::kMemberIdFieldName << 2
+ << repl->getConfigVersion() << UpdatePositionArgs::kMemberIdFieldName << 2
<< UpdatePositionArgs::kAppliedOpTimeFieldName << opTime2.asOpTime().toBSON()
<< UpdatePositionArgs::kAppliedWallTimeFieldName
<< Date_t() + Seconds(opTime2.asOpTime().getSecs())
@@ -3742,8 +3733,7 @@ TEST_F(ReplCoordTest, HelloReturnsErrorInQuiesceModeWhenNodeIsRemoved) {
// Wait for the node to be removed. Test that we increment the topology version.
ASSERT_OK(getReplCoord()->waitForMemberState(MemberState::RS_REMOVED, Seconds(1)));
- ASSERT_EQUALS(removedFromConfig.getConfigVersion(),
- getReplCoord()->getConfig().getConfigVersion());
+ ASSERT_EQUALS(removedFromConfig.getConfigVersion(), getReplCoord()->getConfigVersion());
auto topologyVersionAfterRemoved = getTopoCoord().getTopologyVersion();
ASSERT_EQUALS(topologyVersionAfterQuiesceMode.getCounter() + 1,
topologyVersionAfterRemoved.getCounter());
@@ -4396,8 +4386,7 @@ TEST_F(ReplCoordTest, HelloOnRemovedNode) {
// node1 no longer exists in the replica set config.
ASSERT_OK(getReplCoord()->waitForMemberState(MemberState::RS_REMOVED, Seconds(1)));
- ASSERT_EQUALS(removedFromConfig.getConfigVersion(),
- getReplCoord()->getConfig().getConfigVersion());
+ ASSERT_EQUALS(removedFromConfig.getConfigVersion(), getReplCoord()->getConfigVersion());
const auto maxAwaitTime = Milliseconds(5000);
auto deadline = net->now() + maxAwaitTime;
@@ -4558,8 +4547,7 @@ TEST_F(ReplCoordTest, AwaitHelloRespondsCorrectlyWhenNodeRemovedAndReadded) {
// node1 no longer exists in the replica set config.
ASSERT_OK(getReplCoord()->waitForMemberState(MemberState::RS_REMOVED, Seconds(1)));
- ASSERT_EQUALS(removedFromConfig.getConfigVersion(),
- getReplCoord()->getConfig().getConfigVersion());
+ ASSERT_EQUALS(removedFromConfig.getConfigVersion(), getReplCoord()->getConfigVersion());
getHelloWaitingForRemovedNodeThread.join();
const std::string newHorizonSniName = "newhorizon.com";
auto newHorizon = SplitHorizon::Parameters(newHorizonSniName);
@@ -4644,7 +4632,7 @@ TEST_F(ReplCoordTest, AwaitHelloResponseReturnsOnElectionTimeout) {
ASSERT(getReplCoord()->getMemberState().primary());
// Wait for a hello with deadline past the election timeout.
- auto electionTimeout = getReplCoord()->getConfig().getElectionTimeoutPeriod();
+ auto electionTimeout = getReplCoord()->getConfigElectionTimeoutPeriod();
auto maxAwaitTime = electionTimeout + Milliseconds(5000);
auto deadline = getNet()->now() + maxAwaitTime;
auto electionTimeoutDate = getNet()->now() + electionTimeout;
@@ -6513,7 +6501,7 @@ TEST_F(ReplCoordTest,
getReplCoord()->cancelAndRescheduleElectionTimeout();
- ASSERT_LESS_THAN_OR_EQUALS(until + replCoord->getConfig().getElectionTimeoutPeriod(),
+ ASSERT_LESS_THAN_OR_EQUALS(until + replCoord->getConfigElectionTimeoutPeriod(),
replCoord->getElectionTimeout_forTest());
}
@@ -6611,7 +6599,7 @@ TEST_F(ReplCoordTest,
net->exitNetwork();
ASSERT_OK(getReplCoord()->waitForMemberState(MemberState::RS_REMOVED, Seconds(1)));
- ASSERT_EQUALS(config.getConfigVersion(), getReplCoord()->getConfig().getConfigVersion());
+ ASSERT_EQUALS(config.getConfigVersion(), getReplCoord()->getConfigVersion());
getReplCoord()->cancelAndRescheduleElectionTimeout();
@@ -6665,7 +6653,7 @@ TEST_F(ReplCoordTest,
net->runReadyNetworkOperations();
net->exitNetwork();
- ASSERT_LESS_THAN_OR_EQUALS(heartbeatWhen + replCoord->getConfig().getElectionTimeoutPeriod(),
+ ASSERT_LESS_THAN_OR_EQUALS(heartbeatWhen + replCoord->getConfigElectionTimeoutPeriod(),
replCoord->getElectionTimeout_forTest());
}
@@ -6715,7 +6703,7 @@ TEST_F(ReplCoordTest,
net->runReadyNetworkOperations();
net->exitNetwork();
- ASSERT_GREATER_THAN(heartbeatWhen + replCoord->getConfig().getElectionTimeoutPeriod(),
+ ASSERT_GREATER_THAN(heartbeatWhen + replCoord->getConfigElectionTimeoutPeriod(),
replCoord->getElectionTimeout_forTest());
}
diff --git a/src/mongo/db/repl/replication_coordinator_mock.cpp b/src/mongo/db/repl/replication_coordinator_mock.cpp
index 6324c5043d0..a620117dca0 100644
--- a/src/mongo/db/repl/replication_coordinator_mock.cpp
+++ b/src/mongo/db/repl/replication_coordinator_mock.cpp
@@ -376,6 +376,67 @@ ReplSetConfig ReplicationCoordinatorMock::getConfig() const {
return _getConfigReturnValue;
}
+ConnectionString ReplicationCoordinatorMock::getConfigConnectionString() const {
+ stdx::lock_guard<Mutex> lock(_mutex);
+ return _getConfigReturnValue.getConnectionString();
+}
+
+Milliseconds ReplicationCoordinatorMock::getConfigElectionTimeoutPeriod() const {
+ stdx::lock_guard<Mutex> lock(_mutex);
+ return _getConfigReturnValue.getElectionTimeoutPeriod();
+}
+
+std::vector<MemberConfig> ReplicationCoordinatorMock::getConfigVotingMembers() const {
+ stdx::lock_guard<Mutex> lock(_mutex);
+ return _getConfigReturnValue.votingMembers();
+}
+
+std::int64_t ReplicationCoordinatorMock::getConfigTerm() const {
+ stdx::lock_guard<Mutex> lock(_mutex);
+ return _getConfigReturnValue.getConfigTerm();
+}
+
+std::int64_t ReplicationCoordinatorMock::getConfigVersion() const {
+ stdx::lock_guard<Mutex> lock(_mutex);
+ return _getConfigReturnValue.getConfigVersion();
+}
+
+ConfigVersionAndTerm ReplicationCoordinatorMock::getConfigVersionAndTerm() const {
+ stdx::lock_guard<Mutex> lock(_mutex);
+ return _getConfigReturnValue.getConfigVersionAndTerm();
+}
+
+int ReplicationCoordinatorMock::getConfigNumMembers() const {
+ stdx::lock_guard<Mutex> lock(_mutex);
+ return _getConfigReturnValue.getNumMembers();
+}
+
+Milliseconds ReplicationCoordinatorMock::getConfigHeartbeatTimeoutPeriodMillis() const {
+ stdx::lock_guard<Mutex> lock(_mutex);
+ return _getConfigReturnValue.getHeartbeatTimeoutPeriodMillis();
+}
+
+BSONObj ReplicationCoordinatorMock::getConfigBSON() const {
+ stdx::lock_guard<Mutex> lock(_mutex);
+ return _getConfigReturnValue.toBSON();
+}
+
+const MemberConfig* ReplicationCoordinatorMock::findConfigMemberByHostAndPort(
+ const HostAndPort& hap) const {
+ stdx::lock_guard<Mutex> lock(_mutex);
+ return _getConfigReturnValue.findMemberByHostAndPort(hap);
+}
+
+bool ReplicationCoordinatorMock::isConfigLocalHostAllowed() const {
+ stdx::lock_guard<Mutex> lock(_mutex);
+ return _getConfigReturnValue.isLocalHostAllowed();
+}
+
+Milliseconds ReplicationCoordinatorMock::getConfigHeartbeatInterval() const {
+ stdx::lock_guard<Mutex> lock(_mutex);
+ return _getConfigReturnValue.getHeartbeatInterval();
+}
+
void ReplicationCoordinatorMock::setGetConfigReturnValue(ReplSetConfig returnValue) {
stdx::lock_guard<Mutex> lk(_mutex);
diff --git a/src/mongo/db/repl/replication_coordinator_mock.h b/src/mongo/db/repl/replication_coordinator_mock.h
index 629cd042afe..6bee11cf3b7 100644
--- a/src/mongo/db/repl/replication_coordinator_mock.h
+++ b/src/mongo/db/repl/replication_coordinator_mock.h
@@ -197,6 +197,31 @@ public:
virtual ReplSetConfig getConfig() const;
+ virtual ConnectionString getConfigConnectionString() const override;
+
+ virtual Milliseconds getConfigElectionTimeoutPeriod() const override;
+
+ virtual std::vector<MemberConfig> getConfigVotingMembers() const override;
+
+ virtual std::int64_t getConfigTerm() const override;
+
+ virtual std::int64_t getConfigVersion() const override;
+
+ virtual ConfigVersionAndTerm getConfigVersionAndTerm() const override;
+
+ virtual int getConfigNumMembers() const override;
+
+ virtual Milliseconds getConfigHeartbeatTimeoutPeriodMillis() const override;
+
+ virtual BSONObj getConfigBSON() const override;
+
+ virtual const MemberConfig* findConfigMemberByHostAndPort(
+ const HostAndPort& hap) const override;
+
+ virtual bool isConfigLocalHostAllowed() const override;
+
+ virtual Milliseconds getConfigHeartbeatInterval() const override;
+
virtual void processReplSetGetConfig(BSONObjBuilder* result,
bool commitmentStatus = false,
bool includeNewlyAdded = false);
diff --git a/src/mongo/db/repl/replication_coordinator_noop.cpp b/src/mongo/db/repl/replication_coordinator_noop.cpp
index 33ea5075cc3..281885496f2 100644
--- a/src/mongo/db/repl/replication_coordinator_noop.cpp
+++ b/src/mongo/db/repl/replication_coordinator_noop.cpp
@@ -298,6 +298,55 @@ ReplSetConfig ReplicationCoordinatorNoOp::getConfig() const {
MONGO_UNREACHABLE;
}
+ConnectionString ReplicationCoordinatorNoOp::getConfigConnectionString() const {
+ MONGO_UNREACHABLE;
+}
+
+Milliseconds ReplicationCoordinatorNoOp::getConfigElectionTimeoutPeriod() const {
+ MONGO_UNREACHABLE;
+}
+
+std::vector<MemberConfig> ReplicationCoordinatorNoOp::getConfigVotingMembers() const {
+ MONGO_UNREACHABLE;
+}
+
+std::int64_t ReplicationCoordinatorNoOp::getConfigTerm() const {
+ MONGO_UNREACHABLE;
+}
+
+std::int64_t ReplicationCoordinatorNoOp::getConfigVersion() const {
+ MONGO_UNREACHABLE;
+}
+
+ConfigVersionAndTerm ReplicationCoordinatorNoOp::getConfigVersionAndTerm() const {
+ MONGO_UNREACHABLE;
+}
+
+int ReplicationCoordinatorNoOp::getConfigNumMembers() const {
+ MONGO_UNREACHABLE;
+}
+
+Milliseconds ReplicationCoordinatorNoOp::getConfigHeartbeatTimeoutPeriodMillis() const {
+ MONGO_UNREACHABLE;
+}
+
+BSONObj ReplicationCoordinatorNoOp::getConfigBSON() const {
+ MONGO_UNREACHABLE;
+}
+
+const MemberConfig* ReplicationCoordinatorNoOp::findConfigMemberByHostAndPort(
+ const HostAndPort& hap) const {
+ MONGO_UNREACHABLE;
+}
+
+bool ReplicationCoordinatorNoOp::isConfigLocalHostAllowed() const {
+ MONGO_UNREACHABLE;
+}
+
+Milliseconds ReplicationCoordinatorNoOp::getConfigHeartbeatInterval() const {
+ MONGO_UNREACHABLE;
+}
+
void ReplicationCoordinatorNoOp::processReplSetGetConfig(BSONObjBuilder* result,
bool commitmentStatus,
bool includeNewlyAdded) {
diff --git a/src/mongo/db/repl/replication_coordinator_noop.h b/src/mongo/db/repl/replication_coordinator_noop.h
index 48e4be11c53..fc8b0969058 100644
--- a/src/mongo/db/repl/replication_coordinator_noop.h
+++ b/src/mongo/db/repl/replication_coordinator_noop.h
@@ -173,6 +173,30 @@ public:
ReplSetConfig getConfig() const final;
+ ConnectionString getConfigConnectionString() const final;
+
+ Milliseconds getConfigElectionTimeoutPeriod() const final;
+
+ std::vector<MemberConfig> getConfigVotingMembers() const final;
+
+ std::int64_t getConfigTerm() const final;
+
+ std::int64_t getConfigVersion() const final;
+
+ ConfigVersionAndTerm getConfigVersionAndTerm() const final;
+
+ int getConfigNumMembers() const final;
+
+ Milliseconds getConfigHeartbeatTimeoutPeriodMillis() const final;
+
+ BSONObj getConfigBSON() const final;
+
+ const MemberConfig* findConfigMemberByHostAndPort(const HostAndPort& hap) const final;
+
+ bool isConfigLocalHostAllowed() const final;
+
+ Milliseconds getConfigHeartbeatInterval() const final;
+
void processReplSetGetConfig(BSONObjBuilder*,
bool commitmentStatus = false,
bool includeNewlyAdded = false) final;
diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
index 2c6a45f4d0a..a539d6eb21d 100644
--- a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
+++ b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
@@ -498,7 +498,7 @@ void ReplCoordTest::disableSnapshots() {
void ReplCoordTest::simulateCatchUpAbort() {
NetworkInterfaceMock* net = getNet();
auto heartbeatTimeoutWhen =
- net->now() + getReplCoord()->getConfig().getHeartbeatTimeoutPeriodMillis();
+ net->now() + getReplCoord()->getConfigHeartbeatTimeoutPeriodMillis();
bool hasRequest = false;
net->enterNetwork();
if (net->now() < heartbeatTimeoutWhen) {
diff --git a/src/mongo/db/repl/tenant_migration_donor_service.cpp b/src/mongo/db/repl/tenant_migration_donor_service.cpp
index 0ac4d9c671e..b7a0ee127f3 100644
--- a/src/mongo/db/repl/tenant_migration_donor_service.cpp
+++ b/src/mongo/db/repl/tenant_migration_donor_service.cpp
@@ -685,7 +685,7 @@ ExecutorFuture<void> TenantMigrationDonorService::Instance::_sendRecipientSyncDa
const auto cmdObj = [&] {
auto donorConnString =
- repl::ReplicationCoordinator::get(_serviceContext)->getConfig().getConnectionString();
+ repl::ReplicationCoordinator::get(_serviceContext)->getConfigConnectionString();
RecipientSyncData request;
request.setDbName(NamespaceString::kAdminDb);
@@ -712,7 +712,7 @@ ExecutorFuture<void> TenantMigrationDonorService::Instance::_sendRecipientForget
const CancellationToken& token) {
auto donorConnString =
- repl::ReplicationCoordinator::get(_serviceContext)->getConfig().getConnectionString();
+ repl::ReplicationCoordinator::get(_serviceContext)->getConfigConnectionString();
RecipientForgetMigration request;
request.setDbName(NamespaceString::kAdminDb);
diff --git a/src/mongo/db/repl/tenant_migration_util.h b/src/mongo/db/repl/tenant_migration_util.h
index 0abbd84cc31..18d303d6984 100644
--- a/src/mongo/db/repl/tenant_migration_util.h
+++ b/src/mongo/db/repl/tenant_migration_util.h
@@ -90,8 +90,7 @@ inline Status validateConnectionString(const StringData& donorOrRecipientConnect
// Sanity check to make sure that donor and recipient do not share any hosts.
const auto servers = repl::ReplicationCoordinator::get(cc().getServiceContext())
- ->getConfig()
- .getConnectionString()
+ ->getConfigConnectionString()
.getServers();
for (auto&& server : servers) {
diff --git a/src/mongo/db/s/add_shard_util.cpp b/src/mongo/db/s/add_shard_util.cpp
index 0036ba7f29e..957c2626e26 100644
--- a/src/mongo/db/s/add_shard_util.cpp
+++ b/src/mongo/db/s/add_shard_util.cpp
@@ -53,7 +53,7 @@ AddShard createAddShardCmd(OperationContext* opCtx, const ShardId& shardName) {
shardIdentity.setShardName(shardName.toString());
shardIdentity.setClusterId(ClusterIdentityLoader::get(opCtx)->getClusterId());
shardIdentity.setConfigsvrConnectionString(
- repl::ReplicationCoordinator::get(opCtx)->getConfig().getConnectionString());
+ repl::ReplicationCoordinator::get(opCtx)->getConfigConnectionString());
addShardCmd.setShardIdentity(shardIdentity);
return addShardCmd;
diff --git a/src/mongo/db/s/balancer/migration_manager.cpp b/src/mongo/db/s/balancer/migration_manager.cpp
index 8ab7933ef24..d91e9256096 100644
--- a/src/mongo/db/s/balancer/migration_manager.cpp
+++ b/src/mongo/db/s/balancer/migration_manager.cpp
@@ -471,7 +471,7 @@ std::shared_ptr<Notification<RemoteCommandResponse>> MigrationManager::_schedule
&builder,
nss,
migrateInfo.version,
- repl::ReplicationCoordinator::get(opCtx)->getConfig().getConnectionString(),
+ repl::ReplicationCoordinator::get(opCtx)->getConfigConnectionString(),
migrateInfo.from,
migrateInfo.to,
ChunkRange(migrateInfo.minKey, migrateInfo.maxKey),
diff --git a/src/mongo/db/s/config/configsvr_add_shard_command.cpp b/src/mongo/db/s/config/configsvr_add_shard_command.cpp
index c7003caddb0..bdfce562f53 100644
--- a/src/mongo/db/s/config/configsvr_add_shard_command.cpp
+++ b/src/mongo/db/s/config/configsvr_add_shard_command.cpp
@@ -108,9 +108,8 @@ public:
auto parsedRequest = std::move(swParsedRequest.getValue());
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
- auto rsConfig = replCoord->getConfig();
- auto validationStatus = parsedRequest.validate(rsConfig.isLocalHostAllowed());
+ auto validationStatus = parsedRequest.validate(replCoord->isConfigLocalHostAllowed());
uassertStatusOK(validationStatus);
audit::logAddShard(Client::getCurrent(),
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp b/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
index 1b4a8a26994..c9e7a0c81bd 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
+++ b/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
@@ -338,23 +338,23 @@ protected:
TEST_F(AddShardTest, CreateShardIdentityUpsertForAddShard) {
std::string shardName = "shardName";
- BSONObj expectedBSON = BSON(
- "update"
- << "system.version"
- << "bypassDocumentValidation" << false << "ordered" << true << "updates"
- << BSON_ARRAY(BSON(
- "q" << BSON("_id"
- << "shardIdentity")
- << "u"
- << BSON(
- "shardName"
- << shardName << "clusterId" << _clusterId << "configsvrConnectionString"
- << replicationCoordinator()->getConfig().getConnectionString().toString())
- << "multi" << false << "upsert" << true))
- << "writeConcern"
- << BSON("w"
- << "majority"
- << "wtimeout" << 60000));
+ BSONObj expectedBSON =
+ BSON("update"
+ << "system.version"
+ << "bypassDocumentValidation" << false << "ordered" << true << "updates"
+ << BSON_ARRAY(BSON(
+ "q" << BSON("_id"
+ << "shardIdentity")
+ << "u"
+ << BSON("shardName"
+ << shardName << "clusterId" << _clusterId
+ << "configsvrConnectionString"
+ << replicationCoordinator()->getConfigConnectionString().toString())
+ << "multi" << false << "upsert" << true))
+ << "writeConcern"
+ << BSON("w"
+ << "majority"
+ << "wtimeout" << 60000));
auto addShardCmd = add_shard_util::createAddShardCmd(operationContext(), shardName);
auto actualBSON = add_shard_util::createShardIdentityUpsertForAddShard(addShardCmd);
ASSERT_BSONOBJ_EQ(expectedBSON, actualBSON);
diff --git a/src/mongo/db/s/shard_local.cpp b/src/mongo/db/s/shard_local.cpp
index 506e21ffbf4..8edbdcd95ef 100644
--- a/src/mongo/db/s/shard_local.cpp
+++ b/src/mongo/db/s/shard_local.cpp
@@ -57,8 +57,7 @@ ShardLocal::ShardLocal(const ShardId& id) : Shard(id) {
const ConnectionString ShardLocal::getConnString() const {
return repl::ReplicationCoordinator::get(getGlobalServiceContext())
- ->getConfig()
- .getConnectionString();
+ ->getConfigConnectionString();
}
std::shared_ptr<RemoteCommandTargeter> ShardLocal::getTargeter() const {
diff --git a/src/mongo/db/write_concern.cpp b/src/mongo/db/write_concern.cpp
index a9d831866da..713c95a5c32 100644
--- a/src/mongo/db/write_concern.cpp
+++ b/src/mongo/db/write_concern.cpp
@@ -257,7 +257,7 @@ void WriteConcernResult::appendTo(BSONObjBuilder* result) const {
*/
void waitForNoOplogHolesIfNeeded(OperationContext* opCtx) {
auto const replCoord = repl::ReplicationCoordinator::get(opCtx);
- if (replCoord->getConfig().votingMembers().size() == 1) {
+ if (replCoord->getConfigVotingMembers().size() == 1) {
// It is safe for secondaries in multi-node single voter replica sets to truncate writes if
// there are oplog holes. They can catch up again.
repl::StorageInterface::get(opCtx)->waitForAllEarlierOplogWritesToBeVisible(
diff --git a/src/mongo/embedded/replication_coordinator_embedded.cpp b/src/mongo/embedded/replication_coordinator_embedded.cpp
index dcf19559559..95353e4aa43 100644
--- a/src/mongo/embedded/replication_coordinator_embedded.cpp
+++ b/src/mongo/embedded/replication_coordinator_embedded.cpp
@@ -322,6 +322,55 @@ ReplSetConfig ReplicationCoordinatorEmbedded::getConfig() const {
UASSERT_NOT_IMPLEMENTED;
}
+ConnectionString ReplicationCoordinatorEmbedded::getConfigConnectionString() const {
+ UASSERT_NOT_IMPLEMENTED;
+}
+
+Milliseconds ReplicationCoordinatorEmbedded::getConfigElectionTimeoutPeriod() const {
+ UASSERT_NOT_IMPLEMENTED;
+}
+
+std::vector<MemberConfig> ReplicationCoordinatorEmbedded::getConfigVotingMembers() const {
+ UASSERT_NOT_IMPLEMENTED;
+}
+
+std::int64_t ReplicationCoordinatorEmbedded::getConfigTerm() const {
+ UASSERT_NOT_IMPLEMENTED;
+}
+
+std::int64_t ReplicationCoordinatorEmbedded::getConfigVersion() const {
+ UASSERT_NOT_IMPLEMENTED;
+}
+
+ConfigVersionAndTerm ReplicationCoordinatorEmbedded::getConfigVersionAndTerm() const {
+ UASSERT_NOT_IMPLEMENTED;
+}
+
+int ReplicationCoordinatorEmbedded::getConfigNumMembers() const {
+ UASSERT_NOT_IMPLEMENTED;
+}
+
+Milliseconds ReplicationCoordinatorEmbedded::getConfigHeartbeatTimeoutPeriodMillis() const {
+ UASSERT_NOT_IMPLEMENTED;
+}
+
+BSONObj ReplicationCoordinatorEmbedded::getConfigBSON() const {
+ UASSERT_NOT_IMPLEMENTED;
+}
+
+const MemberConfig* ReplicationCoordinatorEmbedded::findConfigMemberByHostAndPort(
+ const HostAndPort& hap) const {
+ UASSERT_NOT_IMPLEMENTED;
+}
+
+bool ReplicationCoordinatorEmbedded::isConfigLocalHostAllowed() const {
+ UASSERT_NOT_IMPLEMENTED;
+}
+
+Milliseconds ReplicationCoordinatorEmbedded::getConfigHeartbeatInterval() const {
+ UASSERT_NOT_IMPLEMENTED;
+}
+
void ReplicationCoordinatorEmbedded::processReplSetGetConfig(BSONObjBuilder*,
bool commitmentStatus,
bool includeNewlyAdded) {
diff --git a/src/mongo/embedded/replication_coordinator_embedded.h b/src/mongo/embedded/replication_coordinator_embedded.h
index 8d749c2c5c1..77b4129093f 100644
--- a/src/mongo/embedded/replication_coordinator_embedded.h
+++ b/src/mongo/embedded/replication_coordinator_embedded.h
@@ -182,6 +182,30 @@ public:
repl::ReplSetConfig getConfig() const override;
+ ConnectionString getConfigConnectionString() const override;
+
+ Milliseconds getConfigElectionTimeoutPeriod() const override;
+
+ std::vector<repl::MemberConfig> getConfigVotingMembers() const override;
+
+ std::int64_t getConfigTerm() const override;
+
+ std::int64_t getConfigVersion() const override;
+
+ repl::ConfigVersionAndTerm getConfigVersionAndTerm() const override;
+
+ int getConfigNumMembers() const override;
+
+ Milliseconds getConfigHeartbeatTimeoutPeriodMillis() const override;
+
+ BSONObj getConfigBSON() const override;
+
+ const repl::MemberConfig* findConfigMemberByHostAndPort(const HostAndPort& hap) const override;
+
+ bool isConfigLocalHostAllowed() const override;
+
+ Milliseconds getConfigHeartbeatInterval() const override;
+
void processReplSetGetConfig(BSONObjBuilder*,
bool commitmentStatus = false,
bool includeNewlyAdded = false) override;