summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavi Vetriselvan <pavithra.vetriselvan@mongodb.com>2020-11-09 10:13:36 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-11-12 00:08:17 +0000
commit187f9654649452e51b55cc3204cbbfb88742af06 (patch)
treea890ca5864965afa2cca0d0b675e2983f1a4a987
parentadd2cc96db696e9295e3dc7a56337b28e13fd0a8 (diff)
downloadmongo-187f9654649452e51b55cc3204cbbfb88742af06.tar.gz
SERVER-51264 Change IsMasterResponse to HelloResponse on mongod and update local vars/functions
-rw-r--r--src/mongo/db/mirroring_sampler.cpp26
-rw-r--r--src/mongo/db/mirroring_sampler.h10
-rw-r--r--src/mongo/db/mirroring_sampler_test.cpp61
-rw-r--r--src/mongo/db/repl/is_master_response.cpp111
-rw-r--r--src/mongo/db/repl/is_master_response.h28
-rw-r--r--src/mongo/db/repl/member_config.idl2
-rw-r--r--src/mongo/db/repl/replication_coordinator.h20
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp86
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.h23
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp40
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp8
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_test.cpp246
-rw-r--r--src/mongo/db/repl/replication_coordinator_mock.cpp16
-rw-r--r--src/mongo/db/repl/replication_coordinator_mock.h4
-rw-r--r--src/mongo/db/repl/replication_coordinator_noop.cpp6
-rw-r--r--src/mongo/db/repl/replication_coordinator_noop.h4
-rw-r--r--src/mongo/db/repl/replication_coordinator_test_fixture.cpp12
-rw-r--r--src/mongo/db/repl/replication_info.cpp10
-rw-r--r--src/mongo/db/repl/topology_coordinator.cpp14
-rw-r--r--src/mongo/db/repl/topology_coordinator.h2
-rw-r--r--src/mongo/db/repl/topology_version_observer.cpp11
-rw-r--r--src/mongo/db/repl/topology_version_observer.h14
-rw-r--r--src/mongo/db/repl/topology_version_observer_test.cpp8
-rw-r--r--src/mongo/embedded/replication_coordinator_embedded.cpp6
-rw-r--r--src/mongo/embedded/replication_coordinator_embedded.h8
25 files changed, 386 insertions, 390 deletions
diff --git a/src/mongo/db/mirroring_sampler.cpp b/src/mongo/db/mirroring_sampler.cpp
index e6699db0b9a..48aa4930676 100644
--- a/src/mongo/db/mirroring_sampler.cpp
+++ b/src/mongo/db/mirroring_sampler.cpp
@@ -63,15 +63,15 @@ MirroringSampler::SamplingParameters::SamplingParameters(const double ratio,
return std::move(rnd)();
}()) {}
-bool MirroringSampler::shouldSample(const std::shared_ptr<const repl::IsMasterResponse>& imr,
+bool MirroringSampler::shouldSample(const std::shared_ptr<const repl::HelloResponse>& helloResp,
const SamplingParameters& params) const noexcept {
- if (!imr) {
- // If we don't have an IsMasterResponse, we can't know where to send our mirrored request.
+ if (!helloResp) {
+ // If we don't have a HelloResponse, we can't know where to send our mirrored request.
return false;
}
- const auto secondariesCount = imr->getHosts().size() - 1;
- if (!imr->isMaster() || secondariesCount < 1) {
+ const auto secondariesCount = helloResp->getHosts().size() - 1;
+ if (!helloResp->isWritablePrimary() || secondariesCount < 1) {
// If this is not the primary, or there are no eligible secondaries, nothing more to do.
return false;
}
@@ -88,20 +88,20 @@ bool MirroringSampler::shouldSample(const std::shared_ptr<const repl::IsMasterRe
}
std::vector<HostAndPort> MirroringSampler::getRawMirroringTargets(
- const std::shared_ptr<const repl::IsMasterResponse>& isMaster) noexcept {
- invariant(isMaster);
- if (!isMaster->isMaster()) {
+ const std::shared_ptr<const repl::HelloResponse>& helloResp) noexcept {
+ invariant(helloResp);
+ if (!helloResp->isWritablePrimary()) {
// Don't mirror if we're not primary
return {};
}
- const auto& hosts = isMaster->getHosts();
+ const auto& hosts = helloResp->getHosts();
if (hosts.size() < 2) {
// Don't mirror if we're standalone
return {};
}
- const auto& self = isMaster->getPrimary();
+ const auto& self = helloResp->getPrimary();
std::vector<HostAndPort> potentialTargets;
for (auto& host : hosts) {
@@ -114,7 +114,7 @@ std::vector<HostAndPort> MirroringSampler::getRawMirroringTargets(
}
std::vector<HostAndPort> MirroringSampler::getMirroringTargets(
- const std::shared_ptr<const repl::IsMasterResponse>& isMaster,
+ const std::shared_ptr<const repl::HelloResponse>& helloResp,
const double ratio,
RandomFunc rnd,
const int rndMax) noexcept {
@@ -122,11 +122,11 @@ std::vector<HostAndPort> MirroringSampler::getMirroringTargets(
auto sampler = MirroringSampler();
auto samplingParams = SamplingParameters(ratio, rndMax, std::move(rnd));
- if (!sampler.shouldSample(isMaster, samplingParams)) {
+ if (!sampler.shouldSample(helloResp, samplingParams)) {
return {};
}
- return sampler.getRawMirroringTargets(isMaster);
+ return sampler.getRawMirroringTargets(helloResp);
}
} // namespace mongo
diff --git a/src/mongo/db/mirroring_sampler.h b/src/mongo/db/mirroring_sampler.h
index 10132796514..41796f1d713 100644
--- a/src/mongo/db/mirroring_sampler.h
+++ b/src/mongo/db/mirroring_sampler.h
@@ -40,7 +40,7 @@
namespace mongo {
/**
- * Populates a random subset of eligible secondaries (using `IsMasterResponse`
+ * Populates a random subset of eligible secondaries (using `HelloResponse`
* and a ratio) for mirroring. An empty subset for eligible secondaries indicates
* no mirroring is necessary/possible.
*/
@@ -85,14 +85,14 @@ public:
/**
* Use the given imr and params to determine if we should attempt to sample.
*/
- bool shouldSample(const std::shared_ptr<const repl::IsMasterResponse>& imr,
+ bool shouldSample(const std::shared_ptr<const repl::HelloResponse>& imr,
const SamplingParameters& params) const noexcept;
/**
- * Return all eligible hosts from an IsMasterResponse that we should mirror to.
+ * Return all eligible hosts from a HelloResponse that we should mirror to.
*/
std::vector<HostAndPort> getRawMirroringTargets(
- const std::shared_ptr<const repl::IsMasterResponse>& isMaster) noexcept;
+ const std::shared_ptr<const repl::HelloResponse>& isMaster) noexcept;
/**
* Approximate use of the MirroringSampler for testing.
@@ -100,7 +100,7 @@ public:
* In practice, we call constituent functions in sequence to pessimistically spare work.
*/
static std::vector<HostAndPort> getMirroringTargets(
- const std::shared_ptr<const repl::IsMasterResponse>& isMaster,
+ const std::shared_ptr<const repl::HelloResponse>& isMaster,
const double ratio,
RandomFunc rnd = defaultRandomFunc(),
const int rndMax = defaultRandomMax()) noexcept;
diff --git a/src/mongo/db/mirroring_sampler_test.cpp b/src/mongo/db/mirroring_sampler_test.cpp
index 51d2e1140e9..7fcec049007 100644
--- a/src/mongo/db/mirroring_sampler_test.cpp
+++ b/src/mongo/db/mirroring_sampler_test.cpp
@@ -36,57 +36,57 @@
namespace mongo {
DEATH_TEST(MirroringSamplerTest, ValidateNegativeRatio, "invariant") {
- auto dummyIsMaster = std::make_shared<mongo::repl::IsMasterResponse>();
- MirroringSampler::getMirroringTargets(dummyIsMaster, -1);
+ auto dummyHello = std::make_shared<mongo::repl::HelloResponse>();
+ MirroringSampler::getMirroringTargets(dummyHello, -1);
}
DEATH_TEST(MirroringSamplerTest, ValidateLargeRatio, "invariant") {
- auto dummyIsMaster = std::make_shared<mongo::repl::IsMasterResponse>();
- MirroringSampler::getMirroringTargets(dummyIsMaster, 1.1);
+ auto dummyHello = std::make_shared<mongo::repl::HelloResponse>();
+ MirroringSampler::getMirroringTargets(dummyHello, 1.1);
}
-TEST(MirroringSamplerTest, ValidateMissingIsMaster) {
+TEST(MirroringSamplerTest, ValidateMissingHello) {
auto targets = MirroringSampler::getMirroringTargets(nullptr, 1);
ASSERT_EQ(targets.size(), 0);
}
TEST(MirroringSamplerTest, ValidateHostIsPrimary) {
- auto isMaster = std::make_shared<mongo::repl::IsMasterResponse>();
- isMaster->setIsMaster(false);
+ auto hello = std::make_shared<mongo::repl::HelloResponse>();
+ hello->setIsWritablePrimary(false);
- auto targets = MirroringSampler::getMirroringTargets(isMaster, 1);
+ auto targets = MirroringSampler::getMirroringTargets(hello, 1);
ASSERT_EQ(targets.size(), 0);
}
TEST(MirroringSamplerTest, NoEligibleSecondary) {
- auto isMaster = std::make_shared<mongo::repl::IsMasterResponse>();
- isMaster->setIsMaster(true);
- isMaster->setIsSecondary(false);
- isMaster->addHost(mongo::HostAndPort("primary", 12345));
- isMaster->setPrimary(isMaster->getHosts()[0]);
- isMaster->setMe(isMaster->getPrimary());
-
- auto targets = MirroringSampler::getMirroringTargets(isMaster, 1.0);
+ auto hello = std::make_shared<mongo::repl::HelloResponse>();
+ hello->setIsWritablePrimary(true);
+ hello->setIsSecondary(false);
+ hello->addHost(mongo::HostAndPort("primary", 12345));
+ hello->setPrimary(hello->getHosts()[0]);
+ hello->setMe(hello->getPrimary());
+
+ auto targets = MirroringSampler::getMirroringTargets(hello, 1.0);
ASSERT_EQ(targets.size(), 0);
}
class MirroringSamplerFixture : public unittest::Test {
public:
void init(size_t secondariesCount) {
- _isMaster = std::make_shared<mongo::repl::IsMasterResponse>();
- _isMaster->setIsMaster(true);
- _isMaster->setIsSecondary(false);
+ _hello = std::make_shared<mongo::repl::HelloResponse>();
+ _hello->setIsWritablePrimary(true);
+ _hello->setIsSecondary(false);
for (size_t i = 0; i < secondariesCount + 1; i++) {
std::string hostName = "node-" + std::to_string(i);
- _isMaster->addHost(mongo::HostAndPort(hostName, 12345));
+ _hello->addHost(mongo::HostAndPort(hostName, 12345));
}
- _isMaster->setPrimary(_isMaster->getHosts()[0]);
- _isMaster->setMe(_isMaster->getPrimary());
+ _hello->setPrimary(_hello->getHosts()[0]);
+ _hello->setMe(_hello->getPrimary());
_hitCounts.clear();
for (size_t i = 1; i < secondariesCount + 1; i++) {
- _hitCounts[_isMaster->getHosts()[i].toString()] = 0;
+ _hitCounts[_hello->getHosts()[i].toString()] = 0;
}
}
@@ -136,14 +136,14 @@ public:
return std::sqrt(standardDeviation / _hitCounts.size());
}
- auto getIsMaster() const {
- return _isMaster;
+ auto getHello() const {
+ return _hello;
}
const size_t repeats = 100000;
private:
- std::shared_ptr<repl::IsMasterResponse> _isMaster;
+ std::shared_ptr<repl::HelloResponse> _hello;
double _pseudoRandomSeed;
@@ -158,7 +158,7 @@ TEST_F(MirroringSamplerFixture, SamplerFunction) {
for (auto secondaryQ : secondariesCount) {
// Set number of secondaries
init(secondaryQ);
- auto isMaster = getIsMaster();
+ auto hello = getHello();
for (auto ratio : ratios) {
resetPseudoRandomSeed();
@@ -167,8 +167,7 @@ TEST_F(MirroringSamplerFixture, SamplerFunction) {
auto pseudoRandomGen = [&]() -> int { return this->nextPseudoRandom(); };
for (size_t i = 0; i < repeats; i++) {
- auto targets =
- MirroringSampler::getMirroringTargets(isMaster, ratio, pseudoRandomGen);
+ auto targets = MirroringSampler::getMirroringTargets(hello, ratio, pseudoRandomGen);
populteHitCounts(targets);
}
@@ -192,10 +191,10 @@ TEST_F(MirroringSamplerFixture, MirrorAll) {
for (auto secondaryQ : secondariesCount) {
// Set number of secondaries
init(secondaryQ);
- auto isMaster = getIsMaster();
+ auto hello = getHello();
for (size_t i = 0; i < repeats; i++) {
- auto targets = MirroringSampler::getMirroringTargets(isMaster, 1.0);
+ auto targets = MirroringSampler::getMirroringTargets(hello, 1.0);
populteHitCounts(targets);
}
diff --git a/src/mongo/db/repl/is_master_response.cpp b/src/mongo/db/repl/is_master_response.cpp
index eea3cf7b6f9..ef01579fe1c 100644
--- a/src/mongo/db/repl/is_master_response.cpp
+++ b/src/mongo/db/repl/is_master_response.cpp
@@ -76,9 +76,9 @@ const std::string kCodeFieldName = "code";
} // namespace
-IsMasterResponse::IsMasterResponse()
- : _isMaster(false),
- _isMasterSet(false),
+HelloResponse::HelloResponse()
+ : _isWritablePrimary(false),
+ _isWritablePrimarySet(false),
_secondary(false),
_isSecondarySet(false),
_setNameSet(false),
@@ -96,15 +96,15 @@ IsMasterResponse::IsMasterResponse()
_hiddenSet(false),
_buildIndexes(true),
_buildIndexesSet(false),
- _slaveDelay(0),
- _slaveDelaySet(false),
+ _secondaryDelaySecs(0),
+ _secondaryDelaySecsSet(false),
_tagsSet(false),
_meSet(false),
_electionId(OID()),
_configSet(true),
_shutdownInProgress(false) {}
-void IsMasterResponse::addToBSON(BSONObjBuilder* builder, bool useLegacyResponseFields) const {
+void HelloResponse::addToBSON(BSONObjBuilder* builder, bool useLegacyResponseFields) const {
if (_topologyVersion) {
BSONObjBuilder topologyVersionBuilder(builder->subobjStart(kTopologyVersionFieldName));
_topologyVersion->serialize(&topologyVersionBuilder);
@@ -156,11 +156,11 @@ void IsMasterResponse::addToBSON(BSONObjBuilder* builder, bool useLegacyResponse
invariant(_setVersionSet);
builder->append(kSetVersionFieldName, static_cast<int>(_setVersion));
- invariant(_isMasterSet);
+ invariant(_isWritablePrimarySet);
if (useLegacyResponseFields) {
- builder->append(kIsMasterFieldName, _isMaster);
+ builder->append(kIsMasterFieldName, _isWritablePrimary);
} else {
- builder->append(kIsWritablePrimaryFieldName, _isMaster);
+ builder->append(kIsWritablePrimaryFieldName, _isWritablePrimary);
}
invariant(_isSecondarySet);
builder->append(kSecondaryFieldName, _secondary);
@@ -175,12 +175,13 @@ void IsMasterResponse::addToBSON(BSONObjBuilder* builder, bool useLegacyResponse
builder->append(kHiddenFieldName, _hidden);
if (_buildIndexesSet)
builder->append(kBuildIndexesFieldName, _buildIndexes);
- if (_slaveDelaySet) {
+ if (_secondaryDelaySecsSet) {
if (useLegacyResponseFields) {
- builder->appendIntOrLL(kSlaveDelayFieldName, durationCount<Seconds>(_slaveDelay));
+ builder->appendIntOrLL(kSlaveDelayFieldName,
+ durationCount<Seconds>(_secondaryDelaySecs));
} else {
builder->appendIntOrLL(kSecondaryDelaySecsFieldName,
- durationCount<Seconds>(_slaveDelay));
+ durationCount<Seconds>(_secondaryDelaySecs));
}
}
if (_tagsSet) {
@@ -209,25 +210,25 @@ void IsMasterResponse::addToBSON(BSONObjBuilder* builder, bool useLegacyResponse
}
}
-BSONObj IsMasterResponse::toBSON(bool useLegacyResponseFields) const {
+BSONObj HelloResponse::toBSON(bool useLegacyResponseFields) const {
BSONObjBuilder builder;
addToBSON(&builder, useLegacyResponseFields);
return builder.obj();
}
-Status IsMasterResponse::initialize(const BSONObj& doc) {
- Status status = bsonExtractBooleanField(doc, kIsMasterFieldName, &_isMaster);
+Status HelloResponse::initialize(const BSONObj& doc) {
+ Status status = bsonExtractBooleanField(doc, kIsMasterFieldName, &_isWritablePrimary);
if (!status.isOK()) {
return status;
}
- _isMasterSet = true;
+ _isWritablePrimarySet = true;
status = bsonExtractBooleanField(doc, kSecondaryFieldName, &_secondary);
if (!status.isOK()) {
return status;
}
_isSecondarySet = true;
if (doc.hasField(kInfoFieldName)) {
- if (_isMaster || _secondary || !doc.hasField(kIsReplicaSetFieldName) ||
+ if (_isWritablePrimary || _secondary || !doc.hasField(kIsReplicaSetFieldName) ||
!doc[kIsReplicaSetFieldName].booleanSafe()) {
return Status(ErrorCodes::FailedToParse,
str::stream() << "Expected presence of \"" << kInfoFieldName
@@ -268,7 +269,7 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
if (hostElement.type() != String) {
return Status(ErrorCodes::TypeMismatch,
str::stream() << "Elements in \"" << kHostsFieldName
- << "\" array of isMaster response must be of type "
+ << "\" array of hello response must be of type "
<< typeName(String) << " but found type "
<< typeName(hostElement.type()));
}
@@ -288,7 +289,7 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
if (passiveElement.type() != String) {
return Status(ErrorCodes::TypeMismatch,
str::stream() << "Elements in \"" << kPassivesFieldName
- << "\" array of isMaster response must be of type "
+ << "\" array of hello response must be of type "
<< typeName(String) << " but found type "
<< typeName(passiveElement.type()));
}
@@ -308,7 +309,7 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
if (arbiterElement.type() != String) {
return Status(ErrorCodes::TypeMismatch,
str::stream() << "Elements in \"" << kArbitersFieldName
- << "\" array of isMaster response must be of type "
+ << "\" array of hello response must be of type "
<< typeName(String) << " but found type "
<< typeName(arbiterElement.type()));
}
@@ -360,13 +361,13 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
}
if (doc.hasField(kSlaveDelayFieldName)) {
- long long slaveDelaySecs;
- status = bsonExtractIntegerField(doc, kSlaveDelayFieldName, &slaveDelaySecs);
+ long long secondaryDelaySecs;
+ status = bsonExtractIntegerField(doc, kSlaveDelayFieldName, &secondaryDelaySecs);
if (!status.isOK()) {
return status;
}
- _slaveDelaySet = true;
- _slaveDelay = Seconds(slaveDelaySecs);
+ _secondaryDelaySecsSet = true;
+ _secondaryDelaySecs = Seconds(secondaryDelaySecs);
}
if (doc.hasField(kTagsFieldName)) {
@@ -381,7 +382,7 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
return Status(ErrorCodes::TypeMismatch,
str::stream() << "Elements in \"" << kTagsFieldName
<< "\" obj "
- "of isMaster response must be of type "
+ "of hello response must be of type "
<< typeName(String) << " but found type "
<< typeName(tagsElement.type()));
}
@@ -413,7 +414,7 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
return Status(ErrorCodes::TypeMismatch,
str::stream() << "Elements in \"" << kLastWriteOpTimeFieldName
<< "\" obj "
- "of isMaster response must be of type "
+ "of hello response must be of type "
<< typeName(Object) << " but found type "
<< typeName(lastWriteOpTimeElement.type()));
}
@@ -433,7 +434,7 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
return Status(ErrorCodes::TypeMismatch,
str::stream() << "Elements in \"" << kLastWriteDateFieldName
<< "\" obj "
- "of isMaster response must be of type "
+ "of hello response must be of type "
<< typeName(Date) << " but found type "
<< typeName(lastWriteDateElement.type()));
}
@@ -453,7 +454,7 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
return Status(ErrorCodes::TypeMismatch,
str::stream() << "Elements in \"" << kLastMajorityWriteOpTimeFieldName
<< "\" obj "
- "of isMaster response must be of type "
+ "of hello response must be of type "
<< typeName(Object) << " but found type "
<< typeName(lastMajorityWriteOpTimeElement.type()));
}
@@ -474,7 +475,7 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
return Status(ErrorCodes::TypeMismatch,
str::stream() << "Elements in \"" << kLastMajorityWriteDateFieldName
<< "\" obj "
- "of isMaster response must be of type "
+ "of hello response must be of type "
<< typeName(Date) << " but found type "
<< typeName(lastMajorityWriteDateElement.type()));
}
@@ -500,103 +501,103 @@ Status IsMasterResponse::initialize(const BSONObj& doc) {
return Status::OK();
}
-void IsMasterResponse::setIsMaster(bool isMaster) {
- _isMasterSet = true;
- _isMaster = isMaster;
+void HelloResponse::setIsWritablePrimary(bool isWritablePrimary) {
+ _isWritablePrimarySet = true;
+ _isWritablePrimary = isWritablePrimary;
}
-void IsMasterResponse::setIsSecondary(bool secondary) {
+void HelloResponse::setIsSecondary(bool secondary) {
_isSecondarySet = true;
_secondary = secondary;
}
-void IsMasterResponse::setReplSetName(StringData setName) {
+void HelloResponse::setReplSetName(StringData setName) {
_setNameSet = true;
_setName = setName.toString();
}
-void IsMasterResponse::setReplSetVersion(long long version) {
+void HelloResponse::setReplSetVersion(long long version) {
_setVersionSet = true;
_setVersion = version;
}
-void IsMasterResponse::addHost(const HostAndPort& host) {
+void HelloResponse::addHost(const HostAndPort& host) {
_hostsSet = true;
_hosts.push_back(host);
}
-void IsMasterResponse::addPassive(const HostAndPort& passive) {
+void HelloResponse::addPassive(const HostAndPort& passive) {
_passivesSet = true;
_passives.push_back(passive);
}
-void IsMasterResponse::addArbiter(const HostAndPort& arbiter) {
+void HelloResponse::addArbiter(const HostAndPort& arbiter) {
_arbitersSet = true;
_arbiters.push_back(arbiter);
}
-void IsMasterResponse::setPrimary(const HostAndPort& primary) {
+void HelloResponse::setPrimary(const HostAndPort& primary) {
_primarySet = true;
_primary = primary;
}
-void IsMasterResponse::setIsArbiterOnly(bool arbiterOnly) {
+void HelloResponse::setIsArbiterOnly(bool arbiterOnly) {
_arbiterOnlySet = true;
_arbiterOnly = arbiterOnly;
}
-void IsMasterResponse::setIsPassive(bool passive) {
+void HelloResponse::setIsPassive(bool passive) {
_passiveSet = true;
_passive = passive;
}
-void IsMasterResponse::setIsHidden(bool hidden) {
+void HelloResponse::setIsHidden(bool hidden) {
_hiddenSet = true;
_hidden = hidden;
}
-void IsMasterResponse::setShouldBuildIndexes(bool buildIndexes) {
+void HelloResponse::setShouldBuildIndexes(bool buildIndexes) {
_buildIndexesSet = true;
_buildIndexes = buildIndexes;
}
-void IsMasterResponse::setTopologyVersion(TopologyVersion topologyVersion) {
+void HelloResponse::setTopologyVersion(TopologyVersion topologyVersion) {
_topologyVersion = topologyVersion;
}
-void IsMasterResponse::setSlaveDelay(Seconds slaveDelay) {
- _slaveDelaySet = true;
- _slaveDelay = slaveDelay;
+void HelloResponse::setSecondaryDelaySecs(Seconds secondaryDelaySecs) {
+ _secondaryDelaySecsSet = true;
+ _secondaryDelaySecs = secondaryDelaySecs;
}
-void IsMasterResponse::addTag(const std::string& tagKey, const std::string& tagValue) {
+void HelloResponse::addTag(const std::string& tagKey, const std::string& tagValue) {
_tagsSet = true;
_tags[tagKey] = tagValue;
}
-void IsMasterResponse::setMe(const HostAndPort& me) {
+void HelloResponse::setMe(const HostAndPort& me) {
_meSet = true;
_me = me;
}
-void IsMasterResponse::setElectionId(const OID& electionId) {
+void HelloResponse::setElectionId(const OID& electionId) {
_electionId = electionId;
}
-void IsMasterResponse::setLastWrite(const OpTime& lastWriteOpTime, const time_t lastWriteDate) {
+void HelloResponse::setLastWrite(const OpTime& lastWriteOpTime, const time_t lastWriteDate) {
_lastWrite = OpTimeWith<time_t>(lastWriteDate, lastWriteOpTime);
}
-void IsMasterResponse::setLastMajorityWrite(const OpTime& lastMajorityWriteOpTime,
- const time_t lastMajorityWriteDate) {
+void HelloResponse::setLastMajorityWrite(const OpTime& lastMajorityWriteOpTime,
+ const time_t lastMajorityWriteDate) {
_lastMajorityWrite = OpTimeWith<time_t>(lastMajorityWriteDate, lastMajorityWriteOpTime);
}
-void IsMasterResponse::markAsNoConfig() {
+void HelloResponse::markAsNoConfig() {
_configSet = false;
}
-void IsMasterResponse::markAsShutdownInProgress() {
+void HelloResponse::markAsShutdownInProgress() {
_shutdownInProgress = true;
}
diff --git a/src/mongo/db/repl/is_master_response.h b/src/mongo/db/repl/is_master_response.h
index 1efacd1b818..82fc3c00339 100644
--- a/src/mongo/db/repl/is_master_response.h
+++ b/src/mongo/db/repl/is_master_response.h
@@ -49,15 +49,15 @@ class Status;
namespace repl {
/**
- * Response structure for the ismaster command. Only handles responses from nodes
+ * Response structure for the hello command. Only handles responses from nodes
* that are in replset mode.
*/
-class IsMasterResponse {
+class HelloResponse {
public:
- IsMasterResponse();
+ HelloResponse();
/**
- * Initializes this IsMasterResponse from the contents of "doc".
+ * Initializes this HelloResponse from the contents of "doc".
*/
Status initialize(const BSONObj& doc);
@@ -81,8 +81,8 @@ public:
// ===================== Accessors for member variables ================================= //
- bool isMaster() const {
- return _isMaster;
+ bool isWritablePrimary() const {
+ return _isWritablePrimary;
}
bool isSecondary() const {
@@ -133,8 +133,8 @@ public:
return _buildIndexes;
}
- Seconds getSlaveDelay() const {
- return _slaveDelay;
+ Seconds getSecondaryDelaySecs() const {
+ return _secondaryDelaySecs;
}
const stdx::unordered_map<std::string, std::string> getTags() const {
@@ -200,7 +200,7 @@ public:
// ===================== Mutators for member variables ================================= //
- void setIsMaster(bool isMaster);
+ void setIsWritablePrimary(bool isWritablePrimary);
void setIsSecondary(bool secondary);
@@ -226,7 +226,7 @@ public:
void setTopologyVersion(TopologyVersion topologyVersion);
- void setSlaveDelay(Seconds slaveDelay);
+ void setSecondaryDelaySecs(Seconds secondaryDelaySecs);
void addTag(const std::string& tagKey, const std::string& tagValue);
@@ -254,8 +254,8 @@ public:
void markAsShutdownInProgress();
private:
- bool _isMaster;
- bool _isMasterSet;
+ bool _isWritablePrimary;
+ bool _isWritablePrimarySet;
bool _secondary;
bool _isSecondarySet;
std::string _setName;
@@ -278,8 +278,8 @@ private:
bool _hiddenSet;
bool _buildIndexes;
bool _buildIndexesSet;
- Seconds _slaveDelay;
- bool _slaveDelaySet;
+ Seconds _secondaryDelaySecs;
+ bool _secondaryDelaySecsSet;
stdx::unordered_map<std::string, std::string> _tags;
bool _tagsSet;
HostAndPort _me;
diff --git a/src/mongo/db/repl/member_config.idl b/src/mongo/db/repl/member_config.idl
index 946028f6a23..9f937c39eb8 100644
--- a/src/mongo/db/repl/member_config.idl
+++ b/src/mongo/db/repl/member_config.idl
@@ -89,7 +89,7 @@ structs:
type: safeBool
default: false
description: "When this value is true, the replica set hides this instance and does
- not include the member in the output of db.isMaster() or isMaster. This
+ not include the member in the output of db.hello() or hello. This
prevents read operations (i.e. queries) from ever reaching this host by
way of secondary read preference"
slaveDelay:
diff --git a/src/mongo/db/repl/replication_coordinator.h b/src/mongo/db/repl/replication_coordinator.h
index 7bf678c06a7..5360434cfde 100644
--- a/src/mongo/db/repl/replication_coordinator.h
+++ b/src/mongo/db/repl/replication_coordinator.h
@@ -73,7 +73,7 @@ class ReplSetMetadata;
namespace repl {
class BackgroundSync;
-class IsMasterResponse;
+class HelloResponse;
class OpTime;
class OpTimeAndWallTime;
class ReadConcernArgs;
@@ -130,9 +130,9 @@ public:
/**
* We enter quiesce mode during the shutdown process if we are in secondary mode. While in
- * quiesce mode, we allow reads to continue and accept new reads, but we fail isMaster requests
+ * quiesce mode, we allow reads to continue and accept new reads, but we fail hello requests
* with ShutdownInProgress. This function causes us to increment the topologyVersion and start
- * failing isMaster requests with ShutdownInProgress. Returns true if the server entered quiesce
+ * failing hello requests with ShutdownInProgress. Returns true if the server entered quiesce
* mode.
*
* We take in quiesceTime only for reporting purposes. The waiting during quiesce mode happens
@@ -251,7 +251,7 @@ public:
/**
* Returns true if the node can be considered master for the purpose of introspective
- * commands such as isMaster() and rs.status().
+ * commands such as hello() and rs.status().
*/
virtual bool isMasterForReportingPurposes() = 0;
@@ -982,24 +982,24 @@ public:
virtual void incrementTopologyVersion() = 0;
/**
- * Constructs and returns an IsMasterResponse. Will block until the given deadline waiting for a
+ * Constructs and returns a HelloResponse. Will block until the given deadline waiting for a
* significant topology change if the 'counter' field of 'clientTopologyVersion' is equal to the
* current TopologyVersion 'counter' from the TopologyCoordinator. Returns immediately if
* 'clientTopologyVersion' < TopologyVersion of the TopologyCoordinator or if the processId
* differs.
*/
- virtual std::shared_ptr<const IsMasterResponse> awaitIsMasterResponse(
+ virtual std::shared_ptr<const HelloResponse> awaitHelloResponse(
OperationContext* opCtx,
const SplitHorizon::Parameters& horizonParams,
boost::optional<TopologyVersion> clientTopologyVersion,
boost::optional<Date_t> deadline) = 0;
/**
- * The futurized version of `awaitIsMasterResponse()`:
- * * The future is ready for all cases that `awaitIsMasterResponse()` returns immediately.
- * * For cases that `awaitIsMasterResponse()` blocks, calling `get()` on the future is blocking.
+ * The futurized version of `awaitHelloResponse()`:
+ * * The future is ready for all cases that `awaitHelloResponse()` returns immediately.
+ * * For cases that `awaitHelloResponse()` blocks, calling `get()` on the future is blocking.
*/
- virtual SharedSemiFuture<std::shared_ptr<const IsMasterResponse>> getIsMasterResponseFuture(
+ virtual SharedSemiFuture<std::shared_ptr<const HelloResponse>> getHelloResponseFuture(
const SplitHorizon::Parameters& horizonParams,
boost::optional<TopologyVersion> clientTopologyVersion) = 0;
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index f5336233f2c..cf873f1c662 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -541,7 +541,7 @@ void ReplicationCoordinatorImpl::_createHorizonTopologyChangePromiseMapping(With
_horizonToTopologyChangePromiseMap.clear();
for (auto const& [horizon, hostAndPort] : horizonMappings) {
_horizonToTopologyChangePromiseMap.emplace(
- horizon, std::make_shared<SharedPromise<std::shared_ptr<const IsMasterResponse>>>());
+ horizon, std::make_shared<SharedPromise<std::shared_ptr<const HelloResponse>>>());
}
}
@@ -946,7 +946,7 @@ bool ReplicationCoordinatorImpl::enterQuiesceModeIfSecondary(Milliseconds quiesc
_inQuiesceMode = true;
_quiesceDeadline = _replExecutor->now() + quiesceTime;
- // Increment the topology version and respond to all waiting isMaster requests with an error.
+ // Increment the topology version and respond to all waiting hello requests with an error.
_fulfillTopologyChangePromise(lk);
return true;
@@ -2136,7 +2136,7 @@ long long ReplicationCoordinatorImpl::_calculateRemainingQuiesceTimeMillis() con
return remainingQuiesceTimeLong;
}
-std::shared_ptr<IsMasterResponse> ReplicationCoordinatorImpl::_makeIsMasterResponse(
+std::shared_ptr<HelloResponse> ReplicationCoordinatorImpl::_makeHelloResponse(
boost::optional<StringData> horizonString, WithLock lock, const bool hasValidConfig) const {
uassert(ShutdownInProgressQuiesceInfo(_calculateRemainingQuiesceTimeMillis()),
@@ -2144,7 +2144,7 @@ std::shared_ptr<IsMasterResponse> ReplicationCoordinatorImpl::_makeIsMasterRespo
!_inQuiesceMode);
if (!hasValidConfig) {
- auto response = std::make_shared<IsMasterResponse>();
+ auto response = std::make_shared<HelloResponse>();
response->setTopologyVersion(_topCoord->getTopologyVersion());
response->markAsNoConfig();
return response;
@@ -2152,7 +2152,7 @@ std::shared_ptr<IsMasterResponse> ReplicationCoordinatorImpl::_makeIsMasterRespo
// horizonString must be passed in if we are a valid member of the config.
invariant(horizonString);
- auto response = std::make_shared<IsMasterResponse>();
+ auto response = std::make_shared<HelloResponse>();
invariant(getSettings().usingReplSets());
_topCoord->fillIsMasterForReplSet(response, *horizonString);
@@ -2164,21 +2164,21 @@ std::shared_ptr<IsMasterResponse> ReplicationCoordinatorImpl::_makeIsMasterRespo
_currentCommittedSnapshot->getTimestamp().getSecs());
}
- if (response->isMaster() && !_readWriteAbility->canAcceptNonLocalWrites(lock)) {
- // Report that we are secondary to ismaster callers until drain completes.
- response->setIsMaster(false);
+ if (response->isWritablePrimary() && !_readWriteAbility->canAcceptNonLocalWrites(lock)) {
+ // Report that we are secondary and not accepting writes until drain completes.
+ response->setIsWritablePrimary(false);
response->setIsSecondary(true);
}
if (_inShutdown) {
- response->setIsMaster(false);
+ response->setIsWritablePrimary(false);
response->setIsSecondary(false);
}
return response;
}
-SharedSemiFuture<ReplicationCoordinatorImpl::SharedIsMasterResponse>
-ReplicationCoordinatorImpl::_getIsMasterResponseFuture(
+SharedSemiFuture<ReplicationCoordinatorImpl::SharedHelloResponse>
+ReplicationCoordinatorImpl::_getHelloResponseFuture(
WithLock lk,
const SplitHorizon::Parameters& horizonParams,
boost::optional<StringData> horizonString,
@@ -2191,17 +2191,17 @@ ReplicationCoordinatorImpl::_getIsMasterResponseFuture(
const bool hasValidConfig = horizonString != boost::none;
if (!clientTopologyVersion) {
- // The client is not using awaitable isMaster so we respond immediately.
- return SharedSemiFuture<SharedIsMasterResponse>(
- SharedIsMasterResponse(_makeIsMasterResponse(horizonString, lk, hasValidConfig)));
+ // The client is not using awaitable hello so we respond immediately.
+ return SharedSemiFuture<SharedHelloResponse>(
+ SharedHelloResponse(_makeHelloResponse(horizonString, lk, hasValidConfig)));
}
const TopologyVersion topologyVersion = _topCoord->getTopologyVersion();
if (clientTopologyVersion->getProcessId() != topologyVersion.getProcessId()) {
// Getting a different process id indicates that the server has restarted so we return
// immediately with the updated process id.
- return SharedSemiFuture<SharedIsMasterResponse>(
- SharedIsMasterResponse(_makeIsMasterResponse(horizonString, lk, hasValidConfig)));
+ return SharedSemiFuture<SharedHelloResponse>(
+ SharedHelloResponse(_makeHelloResponse(horizonString, lk, hasValidConfig)));
}
auto prevCounter = clientTopologyVersion->getCounter();
@@ -2213,10 +2213,10 @@ ReplicationCoordinatorImpl::_getIsMasterResponseFuture(
prevCounter <= topologyVersionCounter);
if (prevCounter < topologyVersionCounter) {
- // The received isMaster command contains a stale topology version so we respond
+ // The received hello command contains a stale topology version so we respond
// immediately with a more current topology version.
- return SharedSemiFuture<SharedIsMasterResponse>(
- SharedIsMasterResponse(_makeIsMasterResponse(horizonString, lk, hasValidConfig)));
+ return SharedSemiFuture<SharedHelloResponse>(
+ SharedHelloResponse(_makeHelloResponse(horizonString, lk, hasValidConfig)));
}
if (!hasValidConfig) {
@@ -2225,24 +2225,24 @@ ReplicationCoordinatorImpl::_getIsMasterResponseFuture(
auto sniIter =
_sniToValidConfigPromiseMap
.emplace(sni,
- std::make_shared<SharedPromise<std::shared_ptr<const IsMasterResponse>>>())
+ std::make_shared<SharedPromise<std::shared_ptr<const HelloResponse>>>())
.first;
return sniIter->second->getFuture();
}
- // Each awaitable isMaster will wait on their specific horizon. We always expect horizonString
+ // Each awaitable hello will wait on their specific horizon. We always expect horizonString
// to exist in _horizonToTopologyChangePromiseMap.
auto horizonIter = _horizonToTopologyChangePromiseMap.find(*horizonString);
invariant(horizonIter != end(_horizonToTopologyChangePromiseMap));
return horizonIter->second->getFuture();
}
-SharedSemiFuture<ReplicationCoordinatorImpl::SharedIsMasterResponse>
-ReplicationCoordinatorImpl::getIsMasterResponseFuture(
+SharedSemiFuture<ReplicationCoordinatorImpl::SharedHelloResponse>
+ReplicationCoordinatorImpl::getHelloResponseFuture(
const SplitHorizon::Parameters& horizonParams,
boost::optional<TopologyVersion> clientTopologyVersion) {
stdx::lock_guard lk(_mutex);
const auto horizonString = _getHorizonString(lk, horizonParams);
- return _getIsMasterResponseFuture(lk, horizonParams, horizonString, clientTopologyVersion);
+ return _getHelloResponseFuture(lk, horizonParams, horizonString, clientTopologyVersion);
}
boost::optional<StringData> ReplicationCoordinatorImpl::_getHorizonString(
@@ -2258,7 +2258,7 @@ boost::optional<StringData> ReplicationCoordinatorImpl::_getHorizonString(
return horizonString;
}
-std::shared_ptr<const IsMasterResponse> ReplicationCoordinatorImpl::awaitIsMasterResponse(
+std::shared_ptr<const HelloResponse> ReplicationCoordinatorImpl::awaitHelloResponse(
OperationContext* opCtx,
const SplitHorizon::Parameters& horizonParams,
boost::optional<TopologyVersion> clientTopologyVersion,
@@ -2266,8 +2266,7 @@ std::shared_ptr<const IsMasterResponse> ReplicationCoordinatorImpl::awaitIsMaste
stdx::unique_lock lk(_mutex);
const auto horizonString = _getHorizonString(lk, horizonParams);
- auto future =
- _getIsMasterResponseFuture(lk, horizonParams, horizonString, clientTopologyVersion);
+ auto future = _getHelloResponseFuture(lk, horizonParams, horizonString, clientTopologyVersion);
if (future.isReady()) {
return future.get();
}
@@ -2292,9 +2291,9 @@ std::shared_ptr<const IsMasterResponse> ReplicationCoordinatorImpl::awaitIsMaste
// Wait for a topology change with timeout set to deadline.
LOGV2_DEBUG(21342,
1,
- "Waiting for an isMaster response from a topology change or until deadline: "
+ "Waiting for a hello response from a topology change or until deadline: "
"{deadline}. Current TopologyVersion counter is {currentTopologyVersionCounter}",
- "Waiting for an isMaster response from a topology change or until deadline",
+ "Waiting for a hello response from a topology change or until deadline",
"deadline"_attr = deadline.get(),
"currentTopologyVersionCounter"_attr = topologyVersion.getCounter());
auto statusWithIsMaster =
@@ -2307,17 +2306,17 @@ std::shared_ptr<const IsMasterResponse> ReplicationCoordinatorImpl::awaitIsMaste
}
if (status == ErrorCodes::ExceededTimeLimit) {
- // Return an IsMasterResponse with the current topology version on timeout when waiting for
+ // Return a HelloResponse with the current topology version on timeout when waiting for
// a topology change.
stdx::lock_guard lk(_mutex);
HelloMetrics::get(opCtx)->decrementNumAwaitingTopologyChanges();
// A topology change has not occured within the deadline so horizonString is still a good
// indicator of whether we have a valid config.
const bool hasValidConfig = horizonString != boost::none;
- return _makeIsMasterResponse(horizonString, lk, hasValidConfig);
+ return _makeHelloResponse(horizonString, lk, hasValidConfig);
}
- // A topology change has happened so we return an IsMasterResponse with the updated
+ // A topology change has happened so we return a HelloResponse with the updated
// topology version.
uassertStatusOK(status);
return statusWithIsMaster.getValue();
@@ -3939,14 +3938,14 @@ void ReplicationCoordinatorImpl::_errorOnPromisesIfHorizonChanged(WithLock lk,
int oldIndex,
int newIndex) {
if (newIndex < 0) {
- // When a node is removed, always return an isMaster response indicating the server has no
+ // When a node is removed, always return a hello response indicating the server has no
// config set.
return;
}
// We were previously removed but are now rejoining the replica set.
if (_memberState.removed()) {
- // Reply with an error to isMaster requests received while the node had an invalid config.
+ // Reply with an error to hello requests received while the node had an invalid config.
invariant(_horizonToTopologyChangePromiseMap.empty());
for (const auto& [sni, promise] : _sniToValidConfigPromiseMap) {
@@ -3978,7 +3977,7 @@ void ReplicationCoordinatorImpl::_fulfillTopologyChangePromise(WithLock lock) {
_cachedTopologyVersionCounter.store(_topCoord->getTopologyVersion().getCounter());
const auto myState = _topCoord->getMemberState();
const bool hasValidConfig = _rsConfig.isInitialized() && !myState.removed();
- // Create an isMaster response for each horizon the server is knowledgeable about.
+ // Create a hello response for each horizon the server is knowledgeable about.
for (auto iter = _horizonToTopologyChangePromiseMap.begin();
iter != _horizonToTopologyChangePromiseMap.end();
iter++) {
@@ -3988,17 +3987,16 @@ void ReplicationCoordinatorImpl::_fulfillTopologyChangePromise(WithLock lock) {
kQuiesceModeShutdownMessage));
} else {
StringData horizonString = iter->first;
- auto response = _makeIsMasterResponse(horizonString, lock, hasValidConfig);
+ auto response = _makeHelloResponse(horizonString, lock, hasValidConfig);
// Fulfill the promise and replace with a new one for future waiters.
iter->second->emplaceValue(response);
- iter->second =
- std::make_shared<SharedPromise<std::shared_ptr<const IsMasterResponse>>>();
+ iter->second = std::make_shared<SharedPromise<std::shared_ptr<const HelloResponse>>>();
}
}
if (_selfIndex >= 0 && !_sniToValidConfigPromiseMap.empty()) {
- // We are joining the replica set for the first time. Send back an error to isMaster
+ // We are joining the replica set for the first time. Send back an error to hello
// requests that are waiting on a horizon that does not exist in the new config. Otherwise,
- // reply with an updated isMaster response.
+ // reply with an updated hello response.
const auto& reverseHostMappings =
_rsConfig.getMemberAt(_selfIndex).getHorizonReverseHostMappings();
for (const auto& [sni, promise] : _sniToValidConfigPromiseMap) {
@@ -4009,7 +4007,7 @@ void ReplicationCoordinatorImpl::_fulfillTopologyChangePromise(WithLock lock) {
"current replica set config"});
} else {
const auto horizon = sni.empty() ? SplitHorizon::kDefaultHorizon : iter->second;
- const auto response = _makeIsMasterResponse(horizon, lock, hasValidConfig);
+ const auto response = _makeHelloResponse(horizon, lock, hasValidConfig);
promise->emplaceValue(response);
}
}
@@ -4018,7 +4016,7 @@ void ReplicationCoordinatorImpl::_fulfillTopologyChangePromise(WithLock lock) {
HelloMetrics::get(getGlobalServiceContext())->resetNumAwaitingTopologyChanges();
if (_inQuiesceMode) {
- // No more isMaster requests will wait for a topology change, so clear _horizonToPromiseMap.
+ // No more hello requests will wait for a topology change, so clear _horizonToPromiseMap.
_horizonToTopologyChangePromiseMap.clear();
}
}
@@ -4036,7 +4034,7 @@ void ReplicationCoordinatorImpl::_updateWriteAbilityFromTopologyCoordinator(
ReplicationCoordinatorImpl::PostMemberStateUpdateAction
ReplicationCoordinatorImpl::_updateMemberStateFromTopologyCoordinator(WithLock lk) {
- // We want to respond to any waiting isMasters even if our current and target state are the
+ // We want to respond to any waiting hellos even if our current and target state are the
// same as it is possible writes have been disabled during a stepDown but the primary has yet
// to transition to SECONDARY state.
ON_BLOCK_EXIT([&] {
@@ -4501,7 +4499,7 @@ ReplicationCoordinatorImpl::_setCurrentRSConfig(WithLock lk,
"offendingConfigs"_attr = offendingConfigs);
}
- // If the SplitHorizon has changed, reply to all waiting isMasters with an error.
+ // If the SplitHorizon has changed, reply to all waiting hellos with an error.
_errorOnPromisesIfHorizonChanged(lk, opCtx, oldConfig, newConfig, _selfIndex, myIndex);
LOGV2(21392,
diff --git a/src/mongo/db/repl/replication_coordinator_impl.h b/src/mongo/db/repl/replication_coordinator_impl.h
index a3c99e1fd03..d9e2d7d7dad 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.h
+++ b/src/mongo/db/repl/replication_coordinator_impl.h
@@ -358,13 +358,13 @@ public:
virtual void incrementTopologyVersion() override;
- using SharedIsMasterResponse = std::shared_ptr<const IsMasterResponse>;
+ using SharedHelloResponse = std::shared_ptr<const HelloResponse>;
- virtual SharedSemiFuture<SharedIsMasterResponse> getIsMasterResponseFuture(
+ virtual SharedSemiFuture<SharedHelloResponse> getHelloResponseFuture(
const SplitHorizon::Parameters& horizonParams,
boost::optional<TopologyVersion> clientTopologyVersion) override;
- virtual std::shared_ptr<const IsMasterResponse> awaitIsMasterResponse(
+ virtual std::shared_ptr<const HelloResponse> awaitHelloResponse(
OperationContext* opCtx,
const SplitHorizon::Parameters& horizonParams,
boost::optional<TopologyVersion> clientTopologyVersion,
@@ -490,7 +490,7 @@ private:
using ScheduleFn = std::function<StatusWith<executor::TaskExecutor::CallbackHandle>(
const executor::TaskExecutor::CallbackFn& work)>;
- using SharedPromiseOfIsMasterResponse = SharedPromise<std::shared_ptr<const IsMasterResponse>>;
+ using SharedPromiseOfHelloResponse = SharedPromise<std::shared_ptr<const HelloResponse>>;
/**
* Configuration states for a replica set node.
@@ -1234,17 +1234,18 @@ private:
long long _calculateRemainingQuiesceTimeMillis() const;
/**
- * Fills an IsMasterResponse with the appropriate replication related fields. horizonString
+ * Fills a HelloResponse with the appropriate replication related fields. horizonString
* should be passed in if hasValidConfig is true.
*/
- std::shared_ptr<IsMasterResponse> _makeIsMasterResponse(
- boost::optional<StringData> horizonString, WithLock, const bool hasValidConfig) const;
+ std::shared_ptr<HelloResponse> _makeHelloResponse(boost::optional<StringData> horizonString,
+ WithLock,
+ const bool hasValidConfig) const;
/**
- * Creates a semi-future for isMasterResponse. horizonString should be passed in if and only if
+ * Creates a semi-future for HelloResponse. horizonString should be passed in if and only if
* the server is a valid member of the config.
*/
- virtual SharedSemiFuture<SharedIsMasterResponse> _getIsMasterResponseFuture(
+ virtual SharedSemiFuture<SharedHelloResponse> _getHelloResponseFuture(
WithLock,
const SplitHorizon::Parameters& horizonParams,
boost::optional<StringData> horizonString,
@@ -1532,13 +1533,13 @@ private:
// Maps a horizon name to the promise waited on by awaitable isMaster requests when the node
// has an initialized replica set config and is an active member of the replica set.
- StringMap<std::shared_ptr<SharedPromiseOfIsMasterResponse>>
+ StringMap<std::shared_ptr<SharedPromiseOfHelloResponse>>
_horizonToTopologyChangePromiseMap; // (M)
// Maps a requested SNI to the promise waited on by awaitable isMaster requests when the node
// has an unitialized replica set config or is removed. An empty SNI will map to a promise on
// the default horizon.
- StringMap<std::shared_ptr<SharedPromiseOfIsMasterResponse>> _sniToValidConfigPromiseMap; // (M)
+ StringMap<std::shared_ptr<SharedPromiseOfHelloResponse>> _sniToValidConfigPromiseMap; // (M)
// Set to true when we are in the process of shutting down replication.
bool _inShutdown; // (M)
diff --git a/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp
index df8f9ed263f..c45570780cc 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp
@@ -176,15 +176,15 @@ TEST_F(ReplCoordTest, ElectionSucceedsWhenNodeIsTheOnlyElectableNode) {
auto& opCtx = *opCtxPtr;
// Since we're still in drain mode, expect that we report ismaster: false, issecondary:true.
- auto imResponse =
- getReplCoord()->awaitIsMasterResponse(opCtxPtr.get(), {}, boost::none, boost::none);
- ASSERT_FALSE(imResponse->isMaster()) << imResponse->toBSON().toString();
- ASSERT_TRUE(imResponse->isSecondary()) << imResponse->toBSON().toString();
+ auto helloResponse =
+ getReplCoord()->awaitHelloResponse(opCtxPtr.get(), {}, boost::none, boost::none);
+ ASSERT_FALSE(helloResponse->isWritablePrimary()) << helloResponse->toBSON().toString();
+ ASSERT_TRUE(helloResponse->isSecondary()) << helloResponse->toBSON().toString();
signalDrainComplete(&opCtx);
- imResponse =
- getReplCoord()->awaitIsMasterResponse(opCtxPtr.get(), {}, boost::none, boost::none);
- ASSERT_TRUE(imResponse->isMaster()) << imResponse->toBSON().toString();
- ASSERT_FALSE(imResponse->isSecondary()) << imResponse->toBSON().toString();
+ helloResponse =
+ getReplCoord()->awaitHelloResponse(opCtxPtr.get(), {}, boost::none, boost::none);
+ ASSERT_TRUE(helloResponse->isWritablePrimary()) << helloResponse->toBSON().toString();
+ ASSERT_FALSE(helloResponse->isSecondary()) << helloResponse->toBSON().toString();
}
TEST_F(ReplCoordTest, StartElectionDoesNotStartAnElectionWhenNodeIsRecovering) {
@@ -233,15 +233,15 @@ TEST_F(ReplCoordTest, ElectionSucceedsWhenNodeIsTheOnlyNode) {
auto& opCtx = *opCtxPtr;
// Since we're still in drain mode, expect that we report ismaster: false, issecondary:true.
- auto imResponse =
- getReplCoord()->awaitIsMasterResponse(opCtxPtr.get(), {}, boost::none, boost::none);
- ASSERT_FALSE(imResponse->isMaster()) << imResponse->toBSON().toString();
- ASSERT_TRUE(imResponse->isSecondary()) << imResponse->toBSON().toString();
+ auto helloResponse =
+ getReplCoord()->awaitHelloResponse(opCtxPtr.get(), {}, boost::none, boost::none);
+ ASSERT_FALSE(helloResponse->isWritablePrimary()) << helloResponse->toBSON().toString();
+ ASSERT_TRUE(helloResponse->isSecondary()) << helloResponse->toBSON().toString();
signalDrainComplete(&opCtx);
- imResponse =
- getReplCoord()->awaitIsMasterResponse(opCtxPtr.get(), {}, boost::none, boost::none);
- ASSERT_TRUE(imResponse->isMaster()) << imResponse->toBSON().toString();
- ASSERT_FALSE(imResponse->isSecondary()) << imResponse->toBSON().toString();
+ helloResponse =
+ getReplCoord()->awaitHelloResponse(opCtxPtr.get(), {}, boost::none, boost::none);
+ ASSERT_TRUE(helloResponse->isWritablePrimary()) << helloResponse->toBSON().toString();
+ ASSERT_FALSE(helloResponse->isSecondary()) << helloResponse->toBSON().toString();
// Check that only the 'numCatchUpsSkipped' primary catchup conclusion reason was incremented.
ASSERT_EQ(0, ReplicationMetrics::get(opCtxPtr.get()).getNumCatchUpsSucceeded_forTesting());
@@ -2549,10 +2549,10 @@ protected:
simulateSuccessfulV1Voting();
const auto opCtx = makeOperationContext();
- auto imResponse =
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none);
- ASSERT_FALSE(imResponse->isMaster()) << imResponse->toBSON().toString();
- ASSERT_TRUE(imResponse->isSecondary()) << imResponse->toBSON().toString();
+ auto helloResponse =
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none);
+ ASSERT_FALSE(helloResponse->isWritablePrimary()) << helloResponse->toBSON().toString();
+ ASSERT_TRUE(helloResponse->isSecondary()) << helloResponse->toBSON().toString();
return config;
}
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 66b36319c30..4bc85b1073f 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
@@ -770,16 +770,16 @@ TEST_F(ReplCoordHBV1Test, AwaitIsMasterReturnsResponseOnReconfigViaHeartbeat) {
// A reconfig should increment the TopologyVersion counter.
auto expectedCounter = currentTopologyVersion.getCounter() + 1;
auto opCtx = makeOperationContext();
- // awaitIsMasterResponse blocks and waits on a future when the request TopologyVersion equals
+ // awaitHelloResponse blocks and waits on a future when the request TopologyVersion equals
// the current TopologyVersion of the server.
stdx::thread getIsMasterThread([&] {
- auto response = getReplCoord()->awaitIsMasterResponse(
- opCtx.get(), {}, currentTopologyVersion, deadline);
+ auto response =
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, currentTopologyVersion, deadline);
auto topologyVersion = response->getTopologyVersion();
ASSERT_EQUALS(topologyVersion->getCounter(), expectedCounter);
ASSERT_EQUALS(topologyVersion->getProcessId(), expectedProcessId);
- // Ensure the isMasterResponse contains the newly added node.
+ // Ensure the helloResponse contains the newly added node.
const auto hosts = response->getHosts();
ASSERT_EQUALS(3, hosts.size());
ASSERT_EQUALS("node3", hosts[2].host());
diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
index c01888362c0..daadc4de4b1 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
@@ -123,15 +123,14 @@ void killOperation(OperationContext* opCtx) {
opCtx->getServiceContext()->killOperation(lkClient, opCtx);
}
-std::shared_ptr<const repl::IsMasterResponse> awaitIsMasterWithNewOpCtx(
+std::shared_ptr<const repl::HelloResponse> awaitIsMasterWithNewOpCtx(
ReplicationCoordinatorImpl* replCoord,
TopologyVersion topologyVersion,
const repl::SplitHorizon::Parameters& horizonParams,
Date_t deadline) {
auto newClient = getGlobalServiceContext()->makeClient("awaitIsMaster");
auto newOpCtx = newClient->makeOperationContext();
- return replCoord->awaitIsMasterResponse(
- newOpCtx.get(), horizonParams, topologyVersion, deadline);
+ return replCoord->awaitHelloResponse(newOpCtx.get(), horizonParams, topologyVersion, deadline);
}
TEST_F(ReplCoordTest, IsMasterIsFalseDuringStepdown) {
@@ -162,7 +161,7 @@ TEST_F(ReplCoordTest, IsMasterIsFalseDuringStepdown) {
// Test that "ismaster" is immediately false, although "secondary" is not yet true.
auto opCtx = makeOperationContext();
const auto response =
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none);
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none);
ASSERT_TRUE(response->isConfigSet());
BSONObj responseObj = response->toBSON();
ASSERT_FALSE(responseObj["ismaster"].Bool());
@@ -2593,9 +2592,8 @@ TEST_F(StepDownTest, InterruptingStepDownCommandRestoresWriteAvailability) {
// We should not indicate that we are master, nor that we are secondary.
auto opCtx = makeOperationContext();
- auto response =
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none);
- ASSERT_FALSE(response->isMaster());
+ auto response = getReplCoord()->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none);
+ ASSERT_FALSE(response->isWritablePrimary());
ASSERT_FALSE(response->isSecondary());
// Interrupt the ongoing stepdown command.
@@ -2609,8 +2607,8 @@ TEST_F(StepDownTest, InterruptingStepDownCommandRestoresWriteAvailability) {
ASSERT_TRUE(getReplCoord()->getMemberState().primary());
// We should now report that we are master.
- response = getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none);
- ASSERT_TRUE(response->isMaster());
+ response = getReplCoord()->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none);
+ ASSERT_TRUE(response->isWritablePrimary());
ASSERT_FALSE(response->isSecondary());
// This is the important check, that we stepped back up when aborting the stepdown command
@@ -2645,10 +2643,9 @@ TEST_F(StepDownTest, InterruptingAfterUnconditionalStepdownDoesNotRestoreWriteAv
// We should not indicate that we are master, nor that we are secondary.
auto opCtx = makeOperationContext();
- auto response =
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none);
+ auto response = getReplCoord()->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none);
;
- ASSERT_FALSE(response->isMaster());
+ ASSERT_FALSE(response->isWritablePrimary());
ASSERT_FALSE(response->isSecondary());
// Interrupt the ongoing stepdown command.
@@ -2671,8 +2668,8 @@ TEST_F(StepDownTest, InterruptingAfterUnconditionalStepdownDoesNotRestoreWriteAv
ASSERT_TRUE(getReplCoord()->getMemberState().secondary());
// We should still be indicating that we are not master.
- response = getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none);
- ASSERT_FALSE(response->isMaster());
+ response = getReplCoord()->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none);
+ ASSERT_FALSE(response->isWritablePrimary());
// This is the important check, that we didn't accidentally step back up when aborting the
// stepdown command attempt.
@@ -3084,7 +3081,7 @@ TEST_F(ReplCoordTest,
}
}
-TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsCurrentTopologyVersionOnTimeOut) {
+TEST_F(ReplCoordTest, AwaitHelloResponseReturnsCurrentTopologyVersionOnTimeOut) {
init();
assertStartSuccess(BSON("_id"
<< "mySet"
@@ -3101,18 +3098,18 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsCurrentTopologyVersionOnTimeOu
auto expectedTopologyVersion = getTopoCoord().getTopologyVersion();
- // awaitIsMasterResponse blocks and waits on a future when the request TopologyVersion equals
+ // awaitHelloResponse blocks and waits on a future when the request TopologyVersion equals
// the current TopologyVersion of the server.
stdx::thread getIsMasterThread([&] {
const auto response =
awaitIsMasterWithNewOpCtx(getReplCoord(), expectedTopologyVersion, {}, deadline);
auto topologyVersion = response->getTopologyVersion();
- // Assert that on timeout, the returned IsMasterResponse contains the same TopologyVersion.
+ // Assert that on timeout, the returned HelloResponse contains the same TopologyVersion.
ASSERT_EQUALS(topologyVersion->getCounter(), expectedTopologyVersion.getCounter());
ASSERT_EQUALS(topologyVersion->getProcessId(), expectedTopologyVersion.getProcessId());
});
- // Set the network clock to the timeout deadline of awaitIsMasterResponse.
+ // Set the network clock to the timeout deadline of awaitHelloResponse.
getNet()->enterNetwork();
getNet()->advanceTime(deadline);
ASSERT_EQUALS(deadline, getNet()->now());
@@ -3121,7 +3118,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsCurrentTopologyVersionOnTimeOu
}
TEST_F(ReplCoordTest,
- AwaitIsMasterResponseReturnsCurrentTopologyVersionOnRequestWithDifferentProcessId) {
+ AwaitHelloResponseReturnsCurrentTopologyVersionOnRequestWithDifferentProcessId) {
init();
assertStartSuccess(BSON("_id"
<< "mySet"
@@ -3138,7 +3135,7 @@ TEST_F(ReplCoordTest,
auto topologyVersion = getTopoCoord().getTopologyVersion();
- // Get the IsMasterResponse for a request that contains a different process ID. This
+ // Get the HelloResponse for a request that contains a different process ID. This
// should return immediately in all cases instead of waiting for a topology change.
auto differentPid = OID::gen();
ASSERT_NOT_EQUALS(differentPid, topologyVersion.getProcessId());
@@ -3147,7 +3144,7 @@ TEST_F(ReplCoordTest,
auto topologyVersionWithDifferentProcessId =
TopologyVersion(differentPid, topologyVersion.getCounter());
ASSERT_EQUALS(topologyVersionWithDifferentProcessId.getCounter(), topologyVersion.getCounter());
- auto response = getReplCoord()->awaitIsMasterResponse(
+ auto response = getReplCoord()->awaitHelloResponse(
opCtx.get(), {}, topologyVersionWithDifferentProcessId, deadline);
auto responseTopologyVersion = response->getTopologyVersion();
ASSERT_EQUALS(responseTopologyVersion->getProcessId(), topologyVersion.getProcessId());
@@ -3160,7 +3157,7 @@ TEST_F(ReplCoordTest,
topologyVersion.getCounter());
// Test receiving a TopologyVersion with a different process ID and a greater counter.
- response = getReplCoord()->awaitIsMasterResponse(
+ response = getReplCoord()->awaitHelloResponse(
opCtx.get(), {}, topologyVersionWithDifferentProcessId, deadline);
responseTopologyVersion = response->getTopologyVersion();
ASSERT_EQUALS(responseTopologyVersion->getProcessId(), topologyVersion.getProcessId());
@@ -3168,7 +3165,7 @@ TEST_F(ReplCoordTest,
}
TEST_F(ReplCoordTest,
- AwaitIsMasterResponseReturnsCurrentTopologyVersionOnRequestWithStaleTopologyVersion) {
+ AwaitHelloResponseReturnsCurrentTopologyVersionOnRequestWithStaleTopologyVersion) {
init();
assertStartSuccess(BSON("_id"
<< "mySet"
@@ -3190,16 +3187,16 @@ TEST_F(ReplCoordTest,
auto updatedTopologyVersion = getTopoCoord().getTopologyVersion();
ASSERT_LESS_THAN(staleTopologyVersion.getCounter(), updatedTopologyVersion.getCounter());
- // Get the IsMasterResponse for a request that contains a stale TopologyVersion. This should
+ // Get the HelloResponse for a request that contains a stale TopologyVersion. This should
// return immediately instead of blocking and waiting for a topology change.
auto response =
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, staleTopologyVersion, deadline);
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, staleTopologyVersion, deadline);
auto responseTopologyVersion = response->getTopologyVersion();
ASSERT_EQUALS(responseTopologyVersion->getCounter(), updatedTopologyVersion.getCounter());
ASSERT_EQUALS(responseTopologyVersion->getProcessId(), updatedTopologyVersion.getProcessId());
}
-TEST_F(ReplCoordTest, AwaitIsMasterResponseFailsOnRequestWithFutureTopologyVersion) {
+TEST_F(ReplCoordTest, AwaitHelloResponseFailsOnRequestWithFutureTopologyVersion) {
init();
assertStartSuccess(BSON("_id"
<< "mySet"
@@ -3219,15 +3216,15 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseFailsOnRequestWithFutureTopologyVersi
TopologyVersion(topologyVersion.getProcessId(), topologyVersion.getCounter() + 1);
ASSERT_GREATER_THAN(futureTopologyVersion.getCounter(), topologyVersion.getCounter());
- // We should fail immediately if trying to build an IsMasterResponse for a request with a
+ // We should fail immediately if trying to build an HelloResponse for a request with a
// greater TopologyVersion.
ASSERT_THROWS_CODE(
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, futureTopologyVersion, deadline),
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, futureTopologyVersion, deadline),
AssertionException,
31382);
}
-TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnStepDown) {
+TEST_F(ReplCoordTest, AwaitHelloResponseReturnsOnStepDown) {
init();
assertStartSuccess(BSON("_id"
<< "mySet"
@@ -3256,7 +3253,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnStepDown) {
auto timesEnteredFailPoint = waitForHelloFailPoint->setMode(FailPoint::alwaysOn, 0);
ON_BLOCK_EXIT([&] { waitForHelloFailPoint->setMode(FailPoint::off, 0); });
- // awaitIsMasterResponse blocks and waits on a future when the request TopologyVersion equals
+ // awaitHelloResponse blocks and waits on a future when the request TopologyVersion equals
// the current TopologyVersion of the server.
stdx::thread getIsMasterThread([&] {
auto currentTopologyVersion = getTopoCoord().getTopologyVersion();
@@ -3273,7 +3270,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnStepDown) {
// We expect the server to increment the TopologyVersion and respond to waiting IsMasters
// once we disable writes on the node that is stepping down from primary. At this time,
// isMaster will be false but the node will have yet to transition to secondary.
- ASSERT_FALSE(responseAfterDisablingWrites->isMaster());
+ ASSERT_FALSE(responseAfterDisablingWrites->isWritablePrimary());
ASSERT_FALSE(responseAfterDisablingWrites->isSecondary());
ASSERT_EQUALS(responseAfterDisablingWrites->getPrimary().host(), "node1");
@@ -3288,14 +3285,14 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnStepDown) {
const auto topologyVersionStepDownComplete = responseStepdownComplete->getTopologyVersion();
ASSERT_EQUALS(topologyVersionStepDownComplete->getCounter(), expectedCounter);
ASSERT_EQUALS(topologyVersionStepDownComplete->getProcessId(), expectedProcessId);
- ASSERT_FALSE(responseStepdownComplete->isMaster());
+ ASSERT_FALSE(responseStepdownComplete->isWritablePrimary());
ASSERT_TRUE(responseStepdownComplete->isSecondary());
ASSERT_FALSE(responseStepdownComplete->hasPrimary());
});
- // Ensure that awaitIsMasterResponse() is called before triggering a stepdown.
+ // Ensure that awaitHelloResponse() is called before triggering a stepdown.
waitForHelloFailPoint->waitForTimesEntered(timesEnteredFailPoint + 1);
- // A topology change should cause the server to respond to the waiting IsMasterResponse.
+ // A topology change should cause the server to respond to the waiting HelloResponse.
getReplCoord()->stepDown(opCtx.get(), true, Milliseconds(0), Milliseconds(1000));
ASSERT_TRUE(getTopoCoord().getMemberState().secondary());
getIsMasterThread.join();
@@ -3329,7 +3326,7 @@ TEST_F(ReplCoordTest, HelloReturnsErrorOnEnteringQuiesceMode) {
ErrorCodes::ShutdownInProgress);
});
- // Ensure that awaitIsMasterResponse() is called before entering quiesce mode.
+ // Ensure that awaitHelloResponse() is called before entering quiesce mode.
waitForHelloFailPoint->waitForTimesEntered(timesEnteredFailPoint + 1);
ASSERT(getReplCoord()->enterQuiesceModeIfSecondary(Milliseconds(0)));
ASSERT_EQUALS(currentTopologyVersion.getCounter() + 1,
@@ -3415,14 +3412,14 @@ TEST_F(ReplCoordTest, IsMasterReturnsErrorInQuiesceMode) {
// Stale topology version
ASSERT_THROWS_CODE(
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, currentTopologyVersion, deadline),
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, currentTopologyVersion, deadline),
AssertionException,
ErrorCodes::ShutdownInProgress);
// Current topology version
currentTopologyVersion = getTopoCoord().getTopologyVersion();
ASSERT_THROWS_CODE(
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, currentTopologyVersion, deadline),
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, currentTopologyVersion, deadline),
AssertionException,
ErrorCodes::ShutdownInProgress);
@@ -3431,21 +3428,21 @@ TEST_F(ReplCoordTest, IsMasterReturnsErrorInQuiesceMode) {
ASSERT_NOT_EQUALS(differentPid, currentTopologyVersion.getProcessId());
auto topologyVersionWithDifferentProcessId =
TopologyVersion(differentPid, currentTopologyVersion.getCounter());
- ASSERT_THROWS_CODE(getReplCoord()->awaitIsMasterResponse(
+ ASSERT_THROWS_CODE(getReplCoord()->awaitHelloResponse(
opCtx.get(), {}, topologyVersionWithDifferentProcessId, deadline),
AssertionException,
ErrorCodes::ShutdownInProgress);
// No topology version
ASSERT_THROWS_CODE(
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none),
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none),
AssertionException,
ErrorCodes::ShutdownInProgress);
// Check that status includes an extraErrorInfo class. Since we did not advance the clock, we
// should still have the full quiesceTime as our remaining quiesceTime.
try {
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, currentTopologyVersion, deadline);
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, currentTopologyVersion, deadline);
} catch (const DBException& ex) {
ASSERT(ex.extraInfo());
ASSERT(ex.extraInfo<ShutdownInProgressQuiesceInfo>());
@@ -3487,7 +3484,7 @@ TEST_F(ReplCoordTest, QuiesceModeErrorsReturnAccurateRemainingQuiesceTime) {
// Check that status includes an extraErrorInfo class. Since we advanced the clock halfway to
// the quiesce deadline, we should have half of the total quiesceTime left, 500 ms.
try {
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, currentTopologyVersion, deadline);
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, currentTopologyVersion, deadline);
} catch (const DBException& ex) {
ASSERT(ex.extraInfo());
ASSERT(ex.extraInfo<ShutdownInProgressQuiesceInfo>());
@@ -3593,30 +3590,30 @@ TEST_F(ReplCoordTest, IsMasterReturnsErrorInQuiesceModeWhenNodeIsRemoved) {
auto deadline = getNet()->now() + maxAwaitTime;
// Stale topology version
- ASSERT_THROWS_CODE(getReplCoord()->awaitIsMasterResponse(
+ ASSERT_THROWS_CODE(getReplCoord()->awaitHelloResponse(
opCtx.get(), {}, topologyVersionAfterQuiesceMode, deadline),
AssertionException,
ErrorCodes::ShutdownInProgress);
// Current topology version
- ASSERT_THROWS_CODE(getReplCoord()->awaitIsMasterResponse(
- opCtx.get(), {}, topologyVersionAfterRemoved, deadline),
- AssertionException,
- ErrorCodes::ShutdownInProgress);
+ ASSERT_THROWS_CODE(
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, topologyVersionAfterRemoved, deadline),
+ AssertionException,
+ ErrorCodes::ShutdownInProgress);
// Different process ID
auto differentPid = OID::gen();
ASSERT_NOT_EQUALS(differentPid, topologyVersionAfterRemoved.getProcessId());
auto topologyVersionWithDifferentProcessId =
TopologyVersion(differentPid, topologyVersionAfterRemoved.getCounter());
- ASSERT_THROWS_CODE(getReplCoord()->awaitIsMasterResponse(
+ ASSERT_THROWS_CODE(getReplCoord()->awaitHelloResponse(
opCtx.get(), {}, topologyVersionWithDifferentProcessId, deadline),
AssertionException,
ErrorCodes::ShutdownInProgress);
// No topology version
ASSERT_THROWS_CODE(
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none),
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none),
AssertionException,
ErrorCodes::ShutdownInProgress);
}
@@ -3659,7 +3656,7 @@ TEST_F(ReplCoordTest, AllIsMasterFieldsRespectHorizon) {
HostAndPort arbiterHostAndPort(arbiterHostName);
const auto response =
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none);
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none);
const auto hosts = response->getHosts();
ASSERT_EQUALS(hosts[0], primaryHostAndPort);
ASSERT_EQUALS(response->getPrimary(), primaryHostAndPort);
@@ -3679,7 +3676,7 @@ TEST_F(ReplCoordTest, AllIsMasterFieldsRespectHorizon) {
const std::string horizonSniName = "horizon.com";
const auto horizon = SplitHorizon::Parameters(horizonSniName);
const auto response =
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), horizon, boost::none, boost::none);
+ getReplCoord()->awaitHelloResponse(opCtx.get(), horizon, boost::none, boost::none);
const auto hosts = response->getHosts();
ASSERT_EQUALS(hosts[0], primaryHostAndPort);
ASSERT_EQUALS(response->getPrimary(), primaryHostAndPort);
@@ -3691,7 +3688,7 @@ TEST_F(ReplCoordTest, AllIsMasterFieldsRespectHorizon) {
}
}
-TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsErrorOnHorizonChange) {
+TEST_F(ReplCoordTest, AwaitHelloResponseReturnsErrorOnHorizonChange) {
init();
assertStartSuccess(BSON("_id"
<< "mySet"
@@ -3719,7 +3716,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsErrorOnHorizonChange) {
auto timesEnteredFailPoint = waitForHelloFailPoint->setMode(FailPoint::alwaysOn, 0);
ON_BLOCK_EXIT([&] { waitForHelloFailPoint->setMode(FailPoint::off, 0); });
- // awaitIsMasterResponse blocks and waits on a future when the request TopologyVersion equals
+ // awaitHelloResponse blocks and waits on a future when the request TopologyVersion equals
// the current TopologyVersion of the server.
stdx::thread getIsMasterThread([&] {
auto currentTopologyVersion = getTopoCoord().getTopologyVersion();
@@ -3770,8 +3767,8 @@ TEST_F(ReplCoordTest, NonAwaitableIsMasterReturnsNoConfigsOnNodeWithUninitialize
start();
auto opCtx = makeOperationContext();
- const auto response = getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, {}, {});
- ASSERT_FALSE(response->isMaster());
+ const auto response = getReplCoord()->awaitHelloResponse(opCtx.get(), {}, {}, {});
+ ASSERT_FALSE(response->isWritablePrimary());
ASSERT_FALSE(response->isSecondary());
ASSERT_FALSE(response->isConfigSet());
}
@@ -3795,7 +3792,7 @@ TEST_F(ReplCoordTest, AwaitableHelloOnNodeWithUninitializedConfig) {
ASSERT_EQUALS(expectedTopologyVersion.getProcessId(),
responseTopologyVersion->getProcessId());
ASSERT_EQUALS(expectedTopologyVersion.getCounter(), responseTopologyVersion->getCounter());
- ASSERT_FALSE(response->isMaster());
+ ASSERT_FALSE(response->isWritablePrimary());
ASSERT_FALSE(response->isSecondary());
ASSERT_FALSE(response->isConfigSet());
});
@@ -3823,12 +3820,12 @@ TEST_F(ReplCoordTest, AwaitableHelloOnNodeWithUninitializedConfig) {
auto responseTopologyVersion = response->getTopologyVersion();
ASSERT_EQUALS(topologyVersion.getProcessId(), responseTopologyVersion->getProcessId());
ASSERT_EQUALS(topologyVersion.getCounter() + 1, responseTopologyVersion->getCounter());
- ASSERT_FALSE(response->isMaster());
+ ASSERT_FALSE(response->isWritablePrimary());
ASSERT_FALSE(response->isSecondary());
ASSERT_TRUE(response->isConfigSet());
});
- // Ensure that awaitIsMasterResponse() is called before initiating.
+ // Ensure that awaitHelloResponse() is called before initiating.
waitForHelloFailPoint->waitForTimesEntered(timesEnteredFailPoint + 1);
BSONObjBuilder result;
@@ -3857,7 +3854,7 @@ TEST_F(ReplCoordTest, AwaitableIsMasterOnNodeWithUninitializedConfigDifferentTop
currentTopologyVersion.getCounter() + 1);
ASSERT_GREATER_THAN(futureTopologyVersion.getCounter(), currentTopologyVersion.getCounter());
ASSERT_THROWS_CODE(
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, futureTopologyVersion, deadline),
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, futureTopologyVersion, deadline),
AssertionException,
31382);
@@ -3867,10 +3864,10 @@ TEST_F(ReplCoordTest, AwaitableIsMasterOnNodeWithUninitializedConfigDifferentTop
currentTopologyVersion.getCounter() - 1);
ASSERT_LESS_THAN(staleTopologyVersion.getCounter(), currentTopologyVersion.getCounter());
auto response =
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, staleTopologyVersion, deadline);
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, staleTopologyVersion, deadline);
auto responseTopologyVersion = response->getTopologyVersion();
ASSERT_EQUALS(responseTopologyVersion->getCounter(), currentTopologyVersion.getCounter());
- ASSERT_FALSE(response->isMaster());
+ ASSERT_FALSE(response->isWritablePrimary());
ASSERT_FALSE(response->isSecondary());
ASSERT_FALSE(response->isConfigSet());
@@ -3879,12 +3876,12 @@ TEST_F(ReplCoordTest, AwaitableIsMasterOnNodeWithUninitializedConfigDifferentTop
ASSERT_NOT_EQUALS(differentPid, currentTopologyVersion.getProcessId());
auto topologyVersionWithDifferentProcessId =
TopologyVersion(differentPid, currentTopologyVersion.getCounter());
- response = getReplCoord()->awaitIsMasterResponse(
+ response = getReplCoord()->awaitHelloResponse(
opCtx.get(), {}, topologyVersionWithDifferentProcessId, deadline);
responseTopologyVersion = response->getTopologyVersion();
ASSERT_EQUALS(responseTopologyVersion->getProcessId(), currentTopologyVersion.getProcessId());
ASSERT_EQUALS(responseTopologyVersion->getCounter(), currentTopologyVersion.getCounter());
- ASSERT_FALSE(response->isMaster());
+ ASSERT_FALSE(response->isWritablePrimary());
ASSERT_FALSE(response->isSecondary());
ASSERT_FALSE(response->isConfigSet());
@@ -3894,12 +3891,12 @@ TEST_F(ReplCoordTest, AwaitableIsMasterOnNodeWithUninitializedConfigDifferentTop
TopologyVersion(differentPid, currentTopologyVersion.getCounter() + 1);
ASSERT_GREATER_THAN(topologyVersionWithDifferentProcessId.getCounter(),
currentTopologyVersion.getCounter());
- response = getReplCoord()->awaitIsMasterResponse(
+ response = getReplCoord()->awaitHelloResponse(
opCtx.get(), {}, topologyVersionWithDifferentProcessId, deadline);
responseTopologyVersion = response->getTopologyVersion();
ASSERT_EQUALS(responseTopologyVersion->getProcessId(), currentTopologyVersion.getProcessId());
ASSERT_EQUALS(responseTopologyVersion->getCounter(), currentTopologyVersion.getCounter());
- ASSERT_FALSE(response->isMaster());
+ ASSERT_FALSE(response->isWritablePrimary());
ASSERT_FALSE(response->isSecondary());
ASSERT_FALSE(response->isConfigSet());
}
@@ -3916,8 +3913,8 @@ TEST_F(ReplCoordTest, AwaitableIsMasterOnNodeWithUninitializedConfigInvalidHoriz
const auto horizonParam = SplitHorizon::Parameters(horizonSniName);
// Send a non-awaitable isMaster.
- const auto initialResponse = getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, {}, {});
- ASSERT_FALSE(initialResponse->isMaster());
+ const auto initialResponse = getReplCoord()->awaitHelloResponse(opCtx.get(), {}, {}, {});
+ ASSERT_FALSE(initialResponse->isWritablePrimary());
ASSERT_FALSE(initialResponse->isSecondary());
ASSERT_FALSE(initialResponse->isConfigSet());
@@ -3978,7 +3975,7 @@ TEST_F(ReplCoordTest, AwaitableIsMasterOnNodeWithUninitializedConfigSpecifiedHor
ASSERT_EQUALS(hosts[0], horizonOneView);
ASSERT_EQUALS(topologyVersion.getProcessId(), responseTopologyVersion->getProcessId());
ASSERT_EQUALS(topologyVersion.getCounter() + 1, responseTopologyVersion->getCounter());
- ASSERT_FALSE(response->isMaster());
+ ASSERT_FALSE(response->isWritablePrimary());
ASSERT_FALSE(response->isSecondary());
ASSERT_TRUE(response->isConfigSet());
});
@@ -4046,7 +4043,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterUsesDefaultHorizonWhenRequestedHorizonNotFoun
ASSERT_EQUALS(response->getMe(), expectedNodeOneHorizonView);
});
- // Set the network clock to the timeout deadline of awaitIsMasterResponse.
+ // Set the network clock to the timeout deadline of awaitHelloResponse.
getNet()->enterNetwork();
getNet()->advanceTime(deadline);
ASSERT_EQUALS(deadline, getNet()->now());
@@ -4087,7 +4084,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterUsesDefaultHorizonWhenRequestedHorizonNotFoun
});
deadline = getNet()->now() + maxAwaitTime;
- // Set the network clock to the timeout deadline of awaitIsMasterResponse.
+ // Set the network clock to the timeout deadline of awaitHelloResponse.
getNet()->enterNetwork();
getNet()->advanceTime(deadline);
ASSERT_EQUALS(deadline, getNet()->now());
@@ -4136,7 +4133,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterRespondsWithNewHorizon) {
ASSERT_EQUALS(response->getMe(), expectedNodeOneHorizonView);
});
- // Set the network clock to the timeout deadline of awaitIsMasterResponse.
+ // Set the network clock to the timeout deadline of awaitHelloResponse.
getNet()->enterNetwork();
getNet()->advanceTime(deadline);
ASSERT_EQUALS(deadline, getNet()->now());
@@ -4181,7 +4178,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterRespondsWithNewHorizon) {
});
deadline = getNet()->now() + maxAwaitTime;
- // Set the network clock to the timeout deadline of awaitIsMasterResponse.
+ // Set the network clock to the timeout deadline of awaitHelloResponse.
getNet()->enterNetwork();
getNet()->advanceTime(deadline);
ASSERT_EQUALS(deadline, getNet()->now());
@@ -4244,8 +4241,8 @@ TEST_F(ReplCoordTest, IsMasterOnRemovedNode) {
const auto currentTopologyVersion = getTopoCoord().getTopologyVersion();
// Non-awaitable isMaster requests should return immediately.
- auto response = getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, {}, {});
- ASSERT_FALSE(response->isMaster());
+ auto response = getReplCoord()->awaitHelloResponse(opCtx.get(), {}, {}, {});
+ ASSERT_FALSE(response->isWritablePrimary());
ASSERT_FALSE(response->isSecondary());
ASSERT_FALSE(response->isConfigSet());
@@ -4254,7 +4251,7 @@ TEST_F(ReplCoordTest, IsMasterOnRemovedNode) {
currentTopologyVersion.getCounter() + 1);
ASSERT_GREATER_THAN(futureTopologyVersion.getCounter(), currentTopologyVersion.getCounter());
ASSERT_THROWS_CODE(
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, futureTopologyVersion, deadline),
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, futureTopologyVersion, deadline),
AssertionException,
31382);
@@ -4262,11 +4259,10 @@ TEST_F(ReplCoordTest, IsMasterOnRemovedNode) {
const auto staleTopologyVersion = TopologyVersion(currentTopologyVersion.getProcessId(),
currentTopologyVersion.getCounter() - 1);
ASSERT_LESS_THAN(staleTopologyVersion.getCounter(), currentTopologyVersion.getCounter());
- response =
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, staleTopologyVersion, deadline);
+ response = getReplCoord()->awaitHelloResponse(opCtx.get(), {}, staleTopologyVersion, deadline);
auto responseTopologyVersion = response->getTopologyVersion();
ASSERT_EQUALS(responseTopologyVersion->getCounter(), currentTopologyVersion.getCounter());
- ASSERT_FALSE(response->isMaster());
+ ASSERT_FALSE(response->isWritablePrimary());
ASSERT_FALSE(response->isSecondary());
ASSERT_FALSE(response->isConfigSet());
@@ -4275,12 +4271,12 @@ TEST_F(ReplCoordTest, IsMasterOnRemovedNode) {
ASSERT_NOT_EQUALS(differentPid, currentTopologyVersion.getProcessId());
auto topologyVersionWithDifferentProcessId =
TopologyVersion(differentPid, currentTopologyVersion.getCounter());
- response = getReplCoord()->awaitIsMasterResponse(
+ response = getReplCoord()->awaitHelloResponse(
opCtx.get(), {}, topologyVersionWithDifferentProcessId, deadline);
responseTopologyVersion = response->getTopologyVersion();
ASSERT_EQUALS(responseTopologyVersion->getProcessId(), currentTopologyVersion.getProcessId());
ASSERT_EQUALS(responseTopologyVersion->getCounter(), currentTopologyVersion.getCounter());
- ASSERT_FALSE(response->isMaster());
+ ASSERT_FALSE(response->isWritablePrimary());
ASSERT_FALSE(response->isSecondary());
ASSERT_FALSE(response->isConfigSet());
@@ -4290,12 +4286,12 @@ TEST_F(ReplCoordTest, IsMasterOnRemovedNode) {
TopologyVersion(differentPid, currentTopologyVersion.getCounter() + 1);
ASSERT_GREATER_THAN(topologyVersionWithDifferentProcessId.getCounter(),
currentTopologyVersion.getCounter());
- response = getReplCoord()->awaitIsMasterResponse(
+ response = getReplCoord()->awaitHelloResponse(
opCtx.get(), {}, topologyVersionWithDifferentProcessId, deadline);
responseTopologyVersion = response->getTopologyVersion();
ASSERT_EQUALS(responseTopologyVersion->getProcessId(), currentTopologyVersion.getProcessId());
ASSERT_EQUALS(responseTopologyVersion->getCounter(), currentTopologyVersion.getCounter());
- ASSERT_FALSE(response->isMaster());
+ ASSERT_FALSE(response->isWritablePrimary());
AtomicWord<bool> isMasterReturned{false};
// A request with an equal TopologyVersion should wait and timeout once the deadline is reached.
@@ -4307,7 +4303,7 @@ TEST_F(ReplCoordTest, IsMasterOnRemovedNode) {
isMasterReturned.store(true);
responseTopologyVersion = response->getTopologyVersion();
ASSERT_EQUALS(responseTopologyVersion->getCounter(), currentTopologyVersion.getCounter());
- ASSERT_FALSE(response->isMaster());
+ ASSERT_FALSE(response->isWritablePrimary());
ASSERT_FALSE(response->isSecondary());
ASSERT_FALSE(response->isConfigSet());
});
@@ -4362,12 +4358,12 @@ TEST_F(ReplCoordTest, AwaitIsMasterRespondsCorrectlyWhenNodeRemovedAndReadded) {
const auto responseTopologyVersion = response->getTopologyVersion();
ASSERT_EQUALS(responseTopologyVersion->getProcessId(), topologyVersion.getProcessId());
ASSERT_EQUALS(responseTopologyVersion->getCounter(), topologyVersion.getCounter() + 1);
- ASSERT_FALSE(response->isMaster());
+ ASSERT_FALSE(response->isWritablePrimary());
ASSERT_FALSE(response->isSecondary());
ASSERT_FALSE(response->isConfigSet());
});
- // Ensure that awaitIsMasterResponse() is called before triggering a reconfig.
+ // Ensure that awaitHelloResponse() is called before triggering a reconfig.
waitForHelloFailPoint->waitForTimesEntered(timesEnteredFailPoint + 1);
enterNetwork();
@@ -4456,7 +4452,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterRespondsCorrectlyWhenNodeRemovedAndReadded) {
});
deadline = getNet()->now() + maxAwaitTime;
- // Set the network clock to the timeout deadline of awaitIsMasterResponse.
+ // Set the network clock to the timeout deadline of awaitHelloResponse.
getNet()->enterNetwork();
getNet()->advanceTime(deadline);
ASSERT_EQUALS(deadline, getNet()->now());
@@ -4464,7 +4460,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterRespondsCorrectlyWhenNodeRemovedAndReadded) {
getNet()->exitNetwork();
}
-TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnElectionTimeout) {
+TEST_F(ReplCoordTest, AwaitHelloResponseReturnsOnElectionTimeout) {
init();
assertStartSuccess(BSON("_id"
<< "mySet"
@@ -4500,7 +4496,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnElectionTimeout) {
auto timesEnteredFailPoint = waitForHelloFailPoint->setMode(FailPoint::alwaysOn, 0);
ON_BLOCK_EXIT([&] { waitForHelloFailPoint->setMode(FailPoint::off, 0); });
- // awaitIsMasterResponse blocks and waits on a future when the request TopologyVersion equals
+ // awaitHelloResponse blocks and waits on a future when the request TopologyVersion equals
// the current TopologyVersion of the server.
stdx::thread getIsMasterThread([&] {
const auto response =
@@ -4509,12 +4505,12 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnElectionTimeout) {
ASSERT_EQUALS(topologyVersion->getCounter(), expectedCounter);
ASSERT_EQUALS(topologyVersion->getProcessId(), expectedProcessId);
- ASSERT_FALSE(response->isMaster());
+ ASSERT_FALSE(response->isWritablePrimary());
ASSERT_TRUE(response->isSecondary());
ASSERT_FALSE(response->hasPrimary());
});
- // Ensure that awaitIsMasterResponse() is called before triggering an election timeout.
+ // Ensure that awaitHelloResponse() is called before triggering an election timeout.
waitForHelloFailPoint->waitForTimesEntered(timesEnteredFailPoint + 1);
getNet()->enterNetwork();
// Primary steps down after not receiving a response within the election timeout.
@@ -4524,7 +4520,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnElectionTimeout) {
ASSERT_TRUE(getReplCoord()->getMemberState().secondary());
}
-TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnElectionWin) {
+TEST_F(ReplCoordTest, AwaitHelloResponseReturnsOnElectionWin) {
// The config does not have a "term" field, so step-up will not increment the config term
// via reconfig. As a result, step-up only triggers two topology changes.
init();
@@ -4556,8 +4552,8 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnElectionWin) {
auto opCtx = makeOperationContext();
// Calling isMaster without a TopologyVersion field should return immediately.
const auto response =
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none);
- ASSERT_FALSE(response->isMaster());
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none);
+ ASSERT_FALSE(response->isWritablePrimary());
ASSERT_TRUE(response->isSecondary());
ASSERT_FALSE(response->hasPrimary());
@@ -4565,7 +4561,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnElectionWin) {
auto timesEnteredFailPoint = waitForHelloFailPoint->setMode(FailPoint::alwaysOn, 0);
ON_BLOCK_EXIT([&] { waitForHelloFailPoint->setMode(FailPoint::off, 0); });
- // awaitIsMasterResponse blocks and waits on a future when the request TopologyVersion equals
+ // awaitHelloResponse blocks and waits on a future when the request TopologyVersion equals
// the current TopologyVersion of the server.
stdx::thread getIsMasterThread([&] {
const auto responseAfterElection =
@@ -4577,7 +4573,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnElectionWin) {
// We expect the server to increment the TopologyVersion and respond to waiting IsMasters
// once an election is won even if we have yet to signal drain completion.
- ASSERT_FALSE(responseAfterElection->isMaster());
+ ASSERT_FALSE(responseAfterElection->isWritablePrimary());
ASSERT_TRUE(responseAfterElection->isSecondary());
ASSERT_TRUE(responseAfterElection->hasPrimary());
ASSERT_EQUALS(responseAfterElection->getPrimary().host(), "node1");
@@ -4592,14 +4588,14 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnElectionWin) {
ASSERT_EQUALS(topologyVersionAfterDrainComplete->getCounter(), expectedCounter);
ASSERT_EQUALS(topologyVersionAfterDrainComplete->getProcessId(), expectedProcessId);
- ASSERT_TRUE(responseAfterDrainComplete->isMaster());
+ ASSERT_TRUE(responseAfterDrainComplete->isWritablePrimary());
ASSERT_FALSE(responseAfterDrainComplete->isSecondary());
ASSERT_TRUE(responseAfterDrainComplete->hasPrimary());
ASSERT_EQUALS(responseAfterDrainComplete->getPrimary().host(), "node1");
ASSERT(getReplCoord()->getMemberState().primary());
});
- // Ensure that awaitIsMasterResponse() is called before finishing the election.
+ // Ensure that awaitHelloResponse() is called before finishing the election.
waitForHelloFailPoint->waitForTimesEntered(timesEnteredFailPoint + 1);
auto electionTimeoutWhen = getReplCoord()->getElectionTimeout_forTest();
ASSERT_NOT_EQUALS(Date_t(), electionTimeoutWhen);
@@ -4615,7 +4611,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnElectionWin) {
getIsMasterThread.join();
}
-TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnElectionWinWithReconfig) {
+TEST_F(ReplCoordTest, AwaitHelloResponseReturnsOnElectionWinWithReconfig) {
// The config has a "term" field, so step-up will increment the config term
// via reconfig. As a result, step-up triggers three topology changes.
init();
@@ -4647,8 +4643,8 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnElectionWinWithReconfig) {
auto opCtx = makeOperationContext();
// Calling isMaster without a TopologyVersion field should return immediately.
const auto response =
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none);
- ASSERT_FALSE(response->isMaster());
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none);
+ ASSERT_FALSE(response->isWritablePrimary());
ASSERT_TRUE(response->isSecondary());
ASSERT_FALSE(response->hasPrimary());
@@ -4659,7 +4655,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnElectionWinWithReconfig) {
auto timesEnteredFailPoint = waitForHelloFailPoint->setMode(FailPoint::alwaysOn);
ON_BLOCK_EXIT([&] { waitForHelloFailPoint->setMode(FailPoint::off, 0); });
- // awaitIsMasterResponse blocks and waits on a future when the request TopologyVersion equals
+ // awaitHelloResponse blocks and waits on a future when the request TopologyVersion equals
// the current TopologyVersion of the server.
stdx::thread getIsMasterThread([&] {
const auto responseAfterElection =
@@ -4671,7 +4667,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnElectionWinWithReconfig) {
// We expect the server to increment the TopologyVersion and respond to waiting IsMasters
// once an election is won even if we have yet to signal drain completion.
- ASSERT_FALSE(responseAfterElection->isMaster());
+ ASSERT_FALSE(responseAfterElection->isWritablePrimary());
ASSERT_TRUE(responseAfterElection->isSecondary());
ASSERT_TRUE(responseAfterElection->hasPrimary());
ASSERT_EQUALS(responseAfterElection->getPrimary().host(), "node1");
@@ -4685,7 +4681,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnElectionWinWithReconfig) {
ASSERT_EQUALS(topologyVersionAfterReconfig->getCounter(), expectedCounter);
ASSERT_EQUALS(topologyVersionAfterReconfig->getProcessId(), expectedProcessId);
- ASSERT_FALSE(responseAfterReconfig->isMaster());
+ ASSERT_FALSE(responseAfterReconfig->isWritablePrimary());
ASSERT_TRUE(responseAfterReconfig->isSecondary());
ASSERT_TRUE(responseAfterReconfig->hasPrimary());
ASSERT_EQUALS(responseAfterReconfig->getPrimary().host(), "node1");
@@ -4701,14 +4697,14 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnElectionWinWithReconfig) {
ASSERT_EQUALS(topologyVersionAfterDrainComplete->getCounter(), expectedCounter);
ASSERT_EQUALS(topologyVersionAfterDrainComplete->getProcessId(), expectedProcessId);
- ASSERT_TRUE(responseAfterDrainComplete->isMaster());
+ ASSERT_TRUE(responseAfterDrainComplete->isWritablePrimary());
ASSERT_FALSE(responseAfterDrainComplete->isSecondary());
ASSERT_TRUE(responseAfterDrainComplete->hasPrimary());
ASSERT_EQUALS(responseAfterDrainComplete->getPrimary().host(), "node1");
ASSERT(getReplCoord()->getMemberState().primary());
});
- // Ensure that awaitIsMasterResponse() is called before finishing the election.
+ // Ensure that awaitHelloResponse() is called before finishing the election.
waitForHelloFailPoint->waitForTimesEntered(timesEnteredFailPoint + 1);
auto electionTimeoutWhen = getReplCoord()->getElectionTimeout_forTest();
ASSERT_NOT_EQUALS(Date_t(), electionTimeoutWhen);
@@ -4724,12 +4720,12 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnElectionWinWithReconfig) {
getIsMasterThread.join();
}
-TEST_F(ReplCoordTest, IsMasterResponseMentionsLackOfReplicaSetConfig) {
+TEST_F(ReplCoordTest, HelloResponseMentionsLackOfReplicaSetConfig) {
start();
auto opCtx = makeOperationContext();
const auto response =
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none);
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none);
ASSERT_FALSE(response->isConfigSet());
BSONObj responseObj = response->toBSON();
ASSERT_FALSE(responseObj["ismaster"].Bool());
@@ -4737,7 +4733,7 @@ TEST_F(ReplCoordTest, IsMasterResponseMentionsLackOfReplicaSetConfig) {
ASSERT_TRUE(responseObj["isreplicaset"].Bool());
ASSERT_EQUALS("Does not have a valid replica set config", responseObj["info"].String());
- IsMasterResponse roundTripped;
+ HelloResponse roundTripped;
ASSERT_OK(roundTripped.initialize(response->toBSON()));
}
@@ -4769,18 +4765,18 @@ TEST_F(ReplCoordTest, IsMaster) {
auto opCtx = makeOperationContext();
const auto response =
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none);
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none);
ASSERT_EQUALS("mySet", response->getReplSetName());
ASSERT_EQUALS(2, response->getReplSetVersion());
- ASSERT_FALSE(response->isMaster());
+ ASSERT_FALSE(response->isWritablePrimary());
ASSERT_TRUE(response->isSecondary());
// TODO(spencer): test that response includes current primary when there is one.
ASSERT_FALSE(response->isArbiterOnly());
ASSERT_TRUE(response->isPassive());
ASSERT_FALSE(response->isHidden());
ASSERT_TRUE(response->shouldBuildIndexes());
- ASSERT_EQUALS(Seconds(0), response->getSlaveDelay());
+ ASSERT_EQUALS(Seconds(0), response->getSecondaryDelaySecs());
ASSERT_EQUALS(h4, response->getMe());
std::vector<HostAndPort> hosts = response->getHosts();
@@ -4805,7 +4801,7 @@ TEST_F(ReplCoordTest, IsMaster) {
ASSERT_EQUALS(opTime, response->getLastWriteOpTime());
ASSERT_EQUALS(lastWriteDate, response->getLastWriteDate());
- IsMasterResponse roundTripped;
+ HelloResponse roundTripped;
ASSERT_OK(roundTripped.initialize(response->toBSON()));
}
@@ -4832,7 +4828,7 @@ TEST_F(ReplCoordTest, IsMasterWithCommittedSnapshot) {
ASSERT_EQUALS(majorityOpTime, getReplCoord()->getCurrentCommittedSnapshotOpTime());
const auto response =
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none);
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none);
ASSERT_EQUALS(opTime, response->getLastWriteOpTime());
ASSERT_EQUALS(lastWriteDate, response->getLastWriteDate());
@@ -4853,16 +4849,16 @@ TEST_F(ReplCoordTest, IsMasterInShutdown) {
runSingleNodeElection(opCtx.get());
const auto responseBeforeShutdown =
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none);
- ASSERT_TRUE(responseBeforeShutdown->isMaster());
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none);
+ ASSERT_TRUE(responseBeforeShutdown->isWritablePrimary());
ASSERT_FALSE(responseBeforeShutdown->isSecondary());
shutdown(opCtx.get());
// Must not report ourselves as master while we're in shutdown.
const auto responseAfterShutdown =
- getReplCoord()->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none);
- ASSERT_FALSE(responseAfterShutdown->isMaster());
+ getReplCoord()->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none);
+ ASSERT_FALSE(responseAfterShutdown->isWritablePrimary());
ASSERT_FALSE(responseBeforeShutdown->isSecondary());
}
@@ -5115,7 +5111,7 @@ void doReplSetReconfig(ReplicationCoordinatorImpl* replCoord, Status* status, bo
*status = replCoord->processReplSetReconfig(opCtx.get(), args, &garbage);
}
-TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnReplSetReconfig) {
+TEST_F(ReplCoordTest, AwaitHelloResponseReturnsOnReplSetReconfig) {
init();
assertStartSuccess(BSON("_id"
<< "mySet"
@@ -5148,7 +5144,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnReplSetReconfig) {
auto timesEnteredFailPoint = waitForHelloFailPoint->setMode(FailPoint::alwaysOn, 0);
ON_BLOCK_EXIT([&] { waitForHelloFailPoint->setMode(FailPoint::off, 0); });
- // awaitIsMasterResponse blocks and waits on a future when the request TopologyVersion equals
+ // awaitHelloResponse blocks and waits on a future when the request TopologyVersion equals
// the current TopologyVersion of the server.
stdx::thread getIsMasterThread([&] {
const auto response =
@@ -5157,17 +5153,17 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnReplSetReconfig) {
ASSERT_EQUALS(topologyVersion->getCounter(), expectedCounter);
ASSERT_EQUALS(topologyVersion->getProcessId(), expectedProcessId);
- // Ensure the isMasterResponse contains the newly added node.
+ // Ensure the HelloResponse contains the newly added node.
const auto hosts = response->getHosts();
ASSERT_EQUALS(3, hosts.size());
ASSERT_EQUALS("node3", hosts[2].host());
});
- // Ensure that awaitIsMasterResponse() is called before triggering a reconfig.
+ // Ensure that awaitHelloResponse() is called before triggering a reconfig.
waitForHelloFailPoint->waitForTimesEntered(timesEnteredFailPoint + 1);
// Do a reconfig to add a third node to the replica set. A reconfig should cause the server to
- // respond to the waiting IsMasterResponse.
+ // respond to the waiting HelloResponse.
Status status(ErrorCodes::InternalError, "Not Set");
stdx::thread reconfigThread(
[&] { doReplSetReconfig(getReplCoord(), &status, true /* force */); });
@@ -5264,7 +5260,7 @@ void doReplSetReconfigToFewer(ReplicationCoordinatorImpl* replCoord, Status* sta
*status = replCoord->processReplSetReconfig(opCtx.get(), args, &garbage);
}
-TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnReplSetReconfigOnSecondary) {
+TEST_F(ReplCoordTest, AwaitHelloResponseReturnsOnReplSetReconfigOnSecondary) {
init();
assertStartSuccess(BSON("_id"
<< "mySet"
@@ -5299,7 +5295,7 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnReplSetReconfigOnSecondary)
auto timesEnteredFailPoint = waitForHelloFailPoint->setMode(FailPoint::alwaysOn, 0);
ON_BLOCK_EXIT([&] { waitForHelloFailPoint->setMode(FailPoint::off, 0); });
- // awaitIsMasterResponse blocks and waits on a future when the request TopologyVersion equals
+ // awaitHelloResponse blocks and waits on a future when the request TopologyVersion equals
// the current TopologyVersion of the server.
stdx::thread getIsMasterThread([&] {
const auto response =
@@ -5308,14 +5304,14 @@ TEST_F(ReplCoordTest, AwaitIsMasterResponseReturnsOnReplSetReconfigOnSecondary)
ASSERT_EQUALS(topologyVersion->getCounter(), expectedCounter);
ASSERT_EQUALS(topologyVersion->getProcessId(), expectedProcessId);
- // Ensure the isMasterResponse no longer contains the removed node.
+ // Ensure the HelloResponse no longer contains the removed node.
const auto hosts = response->getHosts();
ASSERT_EQUALS(2, hosts.size());
ASSERT_EQUALS("node1", hosts[0].host());
ASSERT_EQUALS("node3", hosts[1].host());
});
- // Ensure that awaitIsMasterResponse() is called before triggering a reconfig.
+ // Ensure that awaitHelloResponse() is called before triggering a reconfig.
waitForHelloFailPoint->waitForTimesEntered(timesEnteredFailPoint + 1);
// Do a reconfig to remove a node from the replica set. A reconfig should cause the server to
diff --git a/src/mongo/db/repl/replication_coordinator_mock.cpp b/src/mongo/db/repl/replication_coordinator_mock.cpp
index e41e13bddc6..b0258189132 100644
--- a/src/mongo/db/repl/replication_coordinator_mock.cpp
+++ b/src/mongo/db/repl/replication_coordinator_mock.cpp
@@ -632,25 +632,25 @@ void ReplicationCoordinatorMock::incrementTopologyVersion() {
return;
}
-SharedSemiFuture<std::shared_ptr<const IsMasterResponse>>
-ReplicationCoordinatorMock::getIsMasterResponseFuture(
+SharedSemiFuture<std::shared_ptr<const HelloResponse>>
+ReplicationCoordinatorMock::getHelloResponseFuture(
const SplitHorizon::Parameters& horizonParams,
boost::optional<TopologyVersion> clientTopologyVersion) {
auto response =
- awaitIsMasterResponse(nullptr, horizonParams, clientTopologyVersion, Date_t::now());
- return SharedSemiFuture<std::shared_ptr<const IsMasterResponse>>(
- std::shared_ptr<const IsMasterResponse>(response));
+ awaitHelloResponse(nullptr, horizonParams, clientTopologyVersion, Date_t::now());
+ return SharedSemiFuture<std::shared_ptr<const HelloResponse>>(
+ std::shared_ptr<const HelloResponse>(response));
}
-std::shared_ptr<const IsMasterResponse> ReplicationCoordinatorMock::awaitIsMasterResponse(
+std::shared_ptr<const HelloResponse> ReplicationCoordinatorMock::awaitHelloResponse(
OperationContext* opCtx,
const SplitHorizon::Parameters& horizonParams,
boost::optional<TopologyVersion> clientTopologyVersion,
boost::optional<Date_t> deadline) {
auto config = getConfig();
- auto response = std::make_shared<IsMasterResponse>();
+ auto response = std::make_shared<HelloResponse>();
response->setReplSetVersion(config.getConfigVersion());
- response->setIsMaster(true);
+ response->setIsWritablePrimary(true);
response->setIsSecondary(false);
if (config.getNumMembers() > 0) {
response->setMe(config.getMemberAt(0).getHostAndPort());
diff --git a/src/mongo/db/repl/replication_coordinator_mock.h b/src/mongo/db/repl/replication_coordinator_mock.h
index 2bb7cb0b20a..00a2b087706 100644
--- a/src/mongo/db/repl/replication_coordinator_mock.h
+++ b/src/mongo/db/repl/replication_coordinator_mock.h
@@ -340,13 +340,13 @@ public:
virtual void incrementTopologyVersion() override;
- virtual std::shared_ptr<const IsMasterResponse> awaitIsMasterResponse(
+ virtual std::shared_ptr<const HelloResponse> awaitHelloResponse(
OperationContext* opCtx,
const SplitHorizon::Parameters& horizonParams,
boost::optional<TopologyVersion> clientTopologyVersion,
boost::optional<Date_t> deadline) override;
- virtual SharedSemiFuture<std::shared_ptr<const IsMasterResponse>> getIsMasterResponseFuture(
+ virtual SharedSemiFuture<std::shared_ptr<const HelloResponse>> getHelloResponseFuture(
const SplitHorizon::Parameters& horizonParams,
boost::optional<TopologyVersion> clientTopologyVersion) override;
diff --git a/src/mongo/db/repl/replication_coordinator_noop.cpp b/src/mongo/db/repl/replication_coordinator_noop.cpp
index 6b867c61a0b..b5544f19f7b 100644
--- a/src/mongo/db/repl/replication_coordinator_noop.cpp
+++ b/src/mongo/db/repl/replication_coordinator_noop.cpp
@@ -496,7 +496,7 @@ void ReplicationCoordinatorNoOp::incrementTopologyVersion() {
MONGO_UNREACHABLE;
}
-std::shared_ptr<const IsMasterResponse> ReplicationCoordinatorNoOp::awaitIsMasterResponse(
+std::shared_ptr<const HelloResponse> ReplicationCoordinatorNoOp::awaitHelloResponse(
OperationContext* opCtx,
const SplitHorizon::Parameters& horizonParams,
boost::optional<TopologyVersion> clientTopologyVersion,
@@ -505,8 +505,8 @@ std::shared_ptr<const IsMasterResponse> ReplicationCoordinatorNoOp::awaitIsMaste
}
-SharedSemiFuture<std::shared_ptr<const IsMasterResponse>>
-ReplicationCoordinatorNoOp::getIsMasterResponseFuture(
+SharedSemiFuture<std::shared_ptr<const HelloResponse>>
+ReplicationCoordinatorNoOp::getHelloResponseFuture(
const SplitHorizon::Parameters& horizonParams,
boost::optional<TopologyVersion> clientTopologyVersion) {
MONGO_UNREACHABLE;
diff --git a/src/mongo/db/repl/replication_coordinator_noop.h b/src/mongo/db/repl/replication_coordinator_noop.h
index e5595eacf48..479ada4c5e3 100644
--- a/src/mongo/db/repl/replication_coordinator_noop.h
+++ b/src/mongo/db/repl/replication_coordinator_noop.h
@@ -275,13 +275,13 @@ public:
TopologyVersion getTopologyVersion() const final;
- std::shared_ptr<const IsMasterResponse> awaitIsMasterResponse(
+ std::shared_ptr<const HelloResponse> awaitHelloResponse(
OperationContext* opCtx,
const SplitHorizon::Parameters& horizonParams,
boost::optional<TopologyVersion> clientTopologyVersion,
boost::optional<Date_t> deadline) final;
- SharedSemiFuture<std::shared_ptr<const IsMasterResponse>> getIsMasterResponseFuture(
+ SharedSemiFuture<std::shared_ptr<const HelloResponse>> getHelloResponseFuture(
const SplitHorizon::Parameters& horizonParams,
boost::optional<TopologyVersion> clientTopologyVersion) final;
diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
index 8acfacc6a7d..8412ca89c31 100644
--- a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
+++ b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
@@ -391,9 +391,9 @@ void ReplCoordTest::simulateSuccessfulV1ElectionWithoutExitingDrainMode(Date_t e
ASSERT(replCoord->getApplierState() == ReplicationCoordinator::ApplierState::Draining);
ASSERT(replCoord->getMemberState().primary()) << replCoord->getMemberState().toString();
- auto imResponse = replCoord->awaitIsMasterResponse(opCtx, {}, boost::none, boost::none);
- ASSERT_FALSE(imResponse->isMaster()) << imResponse->toBSON().toString();
- ASSERT_TRUE(imResponse->isSecondary()) << imResponse->toBSON().toString();
+ auto helloResponse = replCoord->awaitHelloResponse(opCtx, {}, boost::none, boost::none);
+ ASSERT_FALSE(helloResponse->isWritablePrimary()) << helloResponse->toBSON().toString();
+ ASSERT_TRUE(helloResponse->isSecondary()) << helloResponse->toBSON().toString();
}
void ReplCoordTest::simulateSuccessfulV1ElectionAt(Date_t electionTime) {
@@ -404,9 +404,9 @@ void ReplCoordTest::simulateSuccessfulV1ElectionAt(Date_t electionTime) {
signalDrainComplete(opCtx.get());
ASSERT(replCoord->getApplierState() == ReplicationCoordinator::ApplierState::Stopped);
- auto imResponse = replCoord->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none);
- ASSERT_TRUE(imResponse->isMaster()) << imResponse->toBSON().toString();
- ASSERT_FALSE(imResponse->isSecondary()) << imResponse->toBSON().toString();
+ auto helloResponse = replCoord->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none);
+ ASSERT_TRUE(helloResponse->isWritablePrimary()) << helloResponse->toBSON().toString();
+ ASSERT_FALSE(helloResponse->isSecondary()) << helloResponse->toBSON().toString();
ASSERT(replCoord->getMemberState().primary()) << replCoord->getMemberState().toString();
}
diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp
index 9744d05399b..614f7beea36 100644
--- a/src/mongo/db/repl/replication_info.cpp
+++ b/src/mongo/db/repl/replication_info.cpp
@@ -110,14 +110,14 @@ TopologyVersion appendReplicationInfo(OperationContext* opCtx,
deadline = opCtx->getServiceContext()->getPreciseClockSource()->now() +
Milliseconds(*maxAwaitTimeMS);
}
- auto isMasterResponse =
- replCoord->awaitIsMasterResponse(opCtx, horizonParams, clientTopologyVersion, deadline);
- result->appendElements(isMasterResponse->toBSON(useLegacyResponseFields));
+ auto helloResponse =
+ replCoord->awaitHelloResponse(opCtx, horizonParams, clientTopologyVersion, deadline);
+ result->appendElements(helloResponse->toBSON(useLegacyResponseFields));
if (appendReplicationProcess) {
replCoord->appendSlaveInfoData(result);
}
- invariant(isMasterResponse->getTopologyVersion());
- return isMasterResponse->getTopologyVersion().get();
+ invariant(helloResponse->getTopologyVersion());
+ return helloResponse->getTopologyVersion().get();
}
auto currentTopologyVersion = replCoord->getTopologyVersion();
diff --git a/src/mongo/db/repl/topology_coordinator.cpp b/src/mongo/db/repl/topology_coordinator.cpp
index 6a158175c16..8a792865e53 100644
--- a/src/mongo/db/repl/topology_coordinator.cpp
+++ b/src/mongo/db/repl/topology_coordinator.cpp
@@ -2071,7 +2071,7 @@ void TopologyCoordinator::fillMemberData(BSONObjBuilder* result) {
}
}
-void TopologyCoordinator::fillIsMasterForReplSet(std::shared_ptr<IsMasterResponse> response,
+void TopologyCoordinator::fillIsMasterForReplSet(std::shared_ptr<HelloResponse> response,
const StringData& horizonString) const {
invariant(_rsConfig.isInitialized());
response->setTopologyVersion(getTopologyVersion());
@@ -2101,10 +2101,12 @@ void TopologyCoordinator::fillIsMasterForReplSet(std::shared_ptr<IsMasterRespons
}
response->setReplSetVersion(_rsConfig.getConfigVersion());
- // "ismaster" is false if we are not primary. If we're stepping down, we're waiting for the
- // Replication State Transition Lock before we can change to secondary, but we should report
- // "ismaster" false to indicate that we can't accept new writes.
- response->setIsMaster(myState.primary() && !isSteppingDown());
+ // Depending on whether or not the client sent a hello/isMaster request, we set the
+ // "isWritablePrimary"/"ismaster" field to false if we are not primary. If we're stepping down,
+ // we're waiting for the Replication State Transition Lock before we can change to secondary,
+ // but we should report "isWritablePrimary"/"ismaster" false to indicate that we can't accept
+ // new writes.
+ response->setIsWritablePrimary(myState.primary() && !isSteppingDown());
response->setIsSecondary(myState.secondary());
const MemberConfig* curPrimary = getCurrentPrimaryMember();
@@ -2119,7 +2121,7 @@ void TopologyCoordinator::fillIsMasterForReplSet(std::shared_ptr<IsMasterRespons
response->setIsPassive(true);
}
if (selfConfig.getSlaveDelay() > Seconds(0)) {
- response->setSlaveDelay(selfConfig.getSlaveDelay());
+ response->setSecondaryDelaySecs(selfConfig.getSlaveDelay());
}
if (selfConfig.isHidden()) {
response->setIsHidden(true);
diff --git a/src/mongo/db/repl/topology_coordinator.h b/src/mongo/db/repl/topology_coordinator.h
index 4a31f46f19b..372c5d4bdcc 100644
--- a/src/mongo/db/repl/topology_coordinator.h
+++ b/src/mongo/db/repl/topology_coordinator.h
@@ -386,7 +386,7 @@ public:
// Produce a reply to an ismaster request. It is only valid to call this if we are a
// replset. Drivers interpret the isMaster fields according to the Server Discovery and
// Monitoring Spec, see the "Parsing an isMaster response" section.
- void fillIsMasterForReplSet(std::shared_ptr<IsMasterResponse> response,
+ void fillIsMasterForReplSet(std::shared_ptr<HelloResponse> response,
const StringData& horizonString) const;
// Produce member data for the serverStatus command and diagnostic logging.
diff --git a/src/mongo/db/repl/topology_version_observer.cpp b/src/mongo/db/repl/topology_version_observer.cpp
index 4821dd452f4..27fdbafadac 100644
--- a/src/mongo/db/repl/topology_version_observer.cpp
+++ b/src/mongo/db/repl/topology_version_observer.cpp
@@ -103,7 +103,7 @@ void TopologyVersionObserver::shutdown() noexcept {
thread->join();
}
-std::shared_ptr<const IsMasterResponse> TopologyVersionObserver::getCached() noexcept {
+std::shared_ptr<const HelloResponse> TopologyVersionObserver::getCached() noexcept {
if (_state.load() != State::kRunning || _shouldShutdown.load()) {
// Early return if we know there isn't a worker
return {};
@@ -119,7 +119,7 @@ std::string TopologyVersionObserver::toString() const {
return str::stream() << kTopologyVersionObserverName;
}
-void TopologyVersionObserver::_cacheIsMasterResponse(
+void TopologyVersionObserver::_cacheHelloResponse(
OperationContext* opCtx, boost::optional<TopologyVersion> topologyVersion) try {
invariant(opCtx);
@@ -133,7 +133,7 @@ void TopologyVersionObserver::_cacheIsMasterResponse(
});
invariant(_replCoordinator);
- auto future = _replCoordinator->getIsMasterResponseFuture({}, topologyVersion);
+ auto future = _replCoordinator->getHelloResponseFuture({}, topologyVersion);
if (auto response = std::move(future).get(opCtx); response->isConfigSet()) {
stdx::lock_guard lk(_mutex);
@@ -160,8 +160,7 @@ void TopologyVersionObserver::_cacheIsMasterResponse(
throw;
}
- LOGV2_WARNING(
- 40444, "Observer could not retrieve isMasterResponse", "error"_attr = e.toString());
+ LOGV2_WARNING(40444, "Observer could not retrieve HelloResponse", "error"_attr = e.toString());
}
void TopologyVersionObserver::_workerThreadBody() noexcept try {
@@ -232,7 +231,7 @@ void TopologyVersionObserver::_workerThreadBody() noexcept try {
// Pause here so that we can force there to be an opCtx to be interrupted.
topologyVersionObserverExpectsInterruption.pauseWhileSet();
- _cacheIsMasterResponse(opCtxHandle.get(), getTopologyVersion());
+ _cacheHelloResponse(opCtxHandle.get(), getTopologyVersion());
}
} catch (const ExceptionForCat<ErrorCategory::ShutdownError>& e) {
LOGV2_DEBUG(40443, 3, "Observer thread stopped due to shutdown", "error"_attr = e.toString());
diff --git a/src/mongo/db/repl/topology_version_observer.h b/src/mongo/db/repl/topology_version_observer.h
index ff5c2e8564f..1c8bd415d55 100644
--- a/src/mongo/db/repl/topology_version_observer.h
+++ b/src/mongo/db/repl/topology_version_observer.h
@@ -84,12 +84,12 @@ public:
void shutdown() noexcept;
/**
- * Returns a reference (shared pointer) to the cached version of `IsMasterResponse`.
+ * Returns a reference (shared pointer) to the cached version of `HelloResponse`.
* Note that the reference is initially set to `nullptr`.
* Also, the reference is set back to `nullptr` if the thread that updates `_cache` terminates
* due to an error (i.e., exception), or it receives an invalid response.
*/
- std::shared_ptr<const IsMasterResponse> getCached() noexcept;
+ std::shared_ptr<const HelloResponse> getCached() noexcept;
std::string toString() const;
@@ -97,7 +97,7 @@ public:
* Returns true if this TopologyVersionObserver background thread has stopped.
*
* Note that this funtion only returns true after _thread has started and ended, thus implies
- * that getCached() will never return a valid IsMasterResponse again.
+ * that getCached() will never return a valid HelloResponse again.
*/
bool isShutdown() const noexcept {
return _state.loadRelaxed() == State::kShutdown;
@@ -110,7 +110,7 @@ private:
kShutdown,
};
- void _cacheIsMasterResponse(OperationContext*, boost::optional<TopologyVersion>);
+ void _cacheHelloResponse(OperationContext*, boost::optional<TopologyVersion>);
void _workerThreadBody() noexcept;
@@ -118,7 +118,7 @@ private:
* Protects shared accesses to `_cache`, `_observerClient`, and serializes calls to `init()`
* and `shutdown()` methods.
*
- * Accessing the cached `IsMasterResponse` follows a single-producer, multi-consumer model:
+ * Accessing the cached `HelloResponse` follows a single-producer, multi-consumer model:
* consumers are readers of `_cache` and the producer is the observer thread. The assumption
* is that the contention on this lock is insignificant.
*/
@@ -132,8 +132,8 @@ private:
*/
AtomicWord<bool> _shouldShutdown;
- // The reference to the latest cached version of `IsMasterResponse`
- std::shared_ptr<const IsMasterResponse> _cache;
+ // The reference to the latest cached version of `HelloResponse`
+ std::shared_ptr<const HelloResponse> _cache;
/**
* Represents the current state of the observer.
diff --git a/src/mongo/db/repl/topology_version_observer_test.cpp b/src/mongo/db/repl/topology_version_observer_test.cpp
index 3346974649b..25f33d2cc52 100644
--- a/src/mongo/db/repl/topology_version_observer_test.cpp
+++ b/src/mongo/db/repl/topology_version_observer_test.cpp
@@ -126,7 +126,7 @@ TEST_F(TopologyVersionObserverTest, PopulateCache) {
auto opCtx = makeOperationContext();
auto expectedResponse =
- replCoord->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none);
+ replCoord->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none);
ASSERT_EQ(cachedResponse->toBSON().toString(), expectedResponse->toBSON().toString());
}
@@ -151,7 +151,7 @@ TEST_F(TopologyVersionObserverTest, UpdateCache) {
cachedResponse->getTopologyVersion()->getCounter());
auto expectedResponse =
- replCoord->awaitIsMasterResponse(opCtx.get(), {}, boost::none, boost::none);
+ replCoord->awaitHelloResponse(opCtx.get(), {}, boost::none, boost::none);
ASSERT(expectedResponse && expectedResponse->getTopologyVersion());
ASSERT_EQ(newResponse->getTopologyVersion()->getCounter(),
@@ -218,7 +218,7 @@ TEST_F(TopologyVersionObserverTest, HandleQuiesceMode) {
{
// Enter quiesce mode in the replication coordinator to make shutdown errors come from
- // awaitIsMasterResponseFuture()/getIsMasterResponseFuture().
+ // awaitHelloResponseFuture()/getHelloResponseFuture().
auto opCtx = makeOperationContext();
getReplCoord()->enterQuiesceModeIfSecondary(Milliseconds(0));
@@ -226,7 +226,7 @@ TEST_F(TopologyVersionObserverTest, HandleQuiesceMode) {
getNet()->advanceTime(getNet()->now() + sleepTime);
getNet()->exitNetwork();
- ASSERT_THROWS_CODE(replCoord->getIsMasterResponseFuture({}, boost::none).get(opCtx.get()),
+ ASSERT_THROWS_CODE(replCoord->getHelloResponseFuture({}, boost::none).get(opCtx.get()),
AssertionException,
ErrorCodes::ShutdownInProgress);
}
diff --git a/src/mongo/embedded/replication_coordinator_embedded.cpp b/src/mongo/embedded/replication_coordinator_embedded.cpp
index 9fe5b2d4c42..95a6aa2296e 100644
--- a/src/mongo/embedded/replication_coordinator_embedded.cpp
+++ b/src/mongo/embedded/replication_coordinator_embedded.cpp
@@ -522,7 +522,7 @@ void ReplicationCoordinatorEmbedded::incrementTopologyVersion() {
UASSERT_NOT_IMPLEMENTED;
}
-std::shared_ptr<const repl::IsMasterResponse> ReplicationCoordinatorEmbedded::awaitIsMasterResponse(
+std::shared_ptr<const repl::HelloResponse> ReplicationCoordinatorEmbedded::awaitHelloResponse(
OperationContext* opCtx,
const repl::SplitHorizon::Parameters& horizonParams,
boost::optional<TopologyVersion> previous,
@@ -530,8 +530,8 @@ std::shared_ptr<const repl::IsMasterResponse> ReplicationCoordinatorEmbedded::aw
UASSERT_NOT_IMPLEMENTED;
};
-SharedSemiFuture<std::shared_ptr<const IsMasterResponse>>
-ReplicationCoordinatorEmbedded::getIsMasterResponseFuture(
+SharedSemiFuture<std::shared_ptr<const HelloResponse>>
+ReplicationCoordinatorEmbedded::getHelloResponseFuture(
const SplitHorizon::Parameters& horizonParams,
boost::optional<TopologyVersion> clientTopologyVersion) {
UASSERT_NOT_IMPLEMENTED;
diff --git a/src/mongo/embedded/replication_coordinator_embedded.h b/src/mongo/embedded/replication_coordinator_embedded.h
index 0bbc33c1a32..f2cdee67a5a 100644
--- a/src/mongo/embedded/replication_coordinator_embedded.h
+++ b/src/mongo/embedded/replication_coordinator_embedded.h
@@ -284,15 +284,15 @@ public:
void incrementTopologyVersion() override;
- std::shared_ptr<const repl::IsMasterResponse> awaitIsMasterResponse(
+ std::shared_ptr<const repl::HelloResponse> awaitHelloResponse(
OperationContext* opCtx,
const repl::SplitHorizon::Parameters& horizonParams,
boost::optional<TopologyVersion> previous,
boost::optional<Date_t> deadline) override;
- virtual SharedSemiFuture<std::shared_ptr<const repl::IsMasterResponse>>
- getIsMasterResponseFuture(const repl::SplitHorizon::Parameters& horizonParams,
- boost::optional<TopologyVersion> clientTopologyVersion);
+ virtual SharedSemiFuture<std::shared_ptr<const repl::HelloResponse>> getHelloResponseFuture(
+ const repl::SplitHorizon::Parameters& horizonParams,
+ boost::optional<TopologyVersion> clientTopologyVersion);
StatusWith<repl::OpTime> getLatestWriteOpTime(OperationContext* opCtx) const noexcept override;