summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAmirsaman Memaripour <amirsaman.memaripour@mongodb.com>2020-10-22 17:40:11 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-10-23 04:09:49 +0000
commit52d60041fcc406352a6dfcf981b9001f886b1230 (patch)
treeb0c4dece3058d15b0fd10ff203e53128340d31a9 /src
parentdf53ba83283c47d4c0668cb19310e1a23d52901c (diff)
downloadmongo-52d60041fcc406352a6dfcf981b9001f886b1230.tar.gz
SERVER-50511 Change local variables and functions in dbclient files
Diffstat (limited to 'src')
-rw-r--r--src/mongo/client/dbclient_base.cpp17
-rw-r--r--src/mongo/client/dbclient_base.h17
-rw-r--r--src/mongo/client/dbclient_connection.cpp5
-rw-r--r--src/mongo/client/dbclient_cursor.cpp4
-rw-r--r--src/mongo/client/dbclient_rs.cpp342
-rw-r--r--src/mongo/client/dbclient_rs.h63
-rw-r--r--src/mongo/client/dbclient_rs_test.cpp8
-rw-r--r--src/mongo/client/mongo_uri_connect.cpp2
-rw-r--r--src/mongo/client/replica_set_monitor_interface.h4
-rw-r--r--src/mongo/client/scanning_replica_set_monitor.cpp4
-rw-r--r--src/mongo/client/scanning_replica_set_monitor.h2
-rw-r--r--src/mongo/client/streamable_replica_set_monitor.cpp2
-rw-r--r--src/mongo/client/streamable_replica_set_monitor.h2
-rw-r--r--src/mongo/db/dbmessage.h6
-rw-r--r--src/mongo/db/exhaust_cursor_currentop_integration_test.cpp4
-rw-r--r--src/mongo/db/query/query_request.cpp4
-rw-r--r--src/mongo/db/repl/collection_cloner.cpp6
-rw-r--r--src/mongo/db/repl/oplog.cpp2
-rw-r--r--src/mongo/db/repl/rollback_source_impl.cpp14
-rw-r--r--src/mongo/db/repl/tenant_all_database_cloner.cpp2
-rw-r--r--src/mongo/db/repl/tenant_collection_cloner.cpp8
-rw-r--r--src/mongo/db/repl/tenant_database_cloner.cpp2
-rw-r--r--src/mongo/db/repl/tenant_migration_recipient_service.cpp6
-rw-r--r--src/mongo/rpc/legacy_request_builder.cpp2
-rw-r--r--src/mongo/rpc/legacy_request_test.cpp2
-rw-r--r--src/mongo/rpc/metadata.cpp2
-rw-r--r--src/mongo/rpc/metadata_test.cpp2
-rw-r--r--src/mongo/rpc/op_msg_integration_test.cpp12
-rw-r--r--src/mongo/s/commands/strategy.cpp2
-rw-r--r--src/mongo/scripting/engine.cpp2
30 files changed, 279 insertions, 271 deletions
diff --git a/src/mongo/client/dbclient_base.cpp b/src/mongo/client/dbclient_base.cpp
index 9a7c87eed66..5855485ca8e 100644
--- a/src/mongo/client/dbclient_base.cpp
+++ b/src/mongo/client/dbclient_base.cpp
@@ -95,8 +95,9 @@ bool DBClientBase::isOk(const BSONObj& o) {
return o["ok"].trueValue();
}
-bool DBClientBase::isNotMasterErrorString(const BSONElement& e) {
- return e.type() == String && str::contains(e.valuestr(), "not master");
+bool DBClientBase::isNotPrimaryErrorString(const BSONElement& e) {
+ return e.type() == String &&
+ (str::contains(e.valuestr(), "not primary") || str::contains(e.valuestr(), "not master"));
}
@@ -582,7 +583,7 @@ void DBClientBase::logout(const string& dbname, BSONObj& info) {
runCommand(dbname, BSON("logout" << 1), info);
}
-bool DBClientBase::isMaster(bool& isMaster, BSONObj* info) {
+bool DBClientBase::isPrimary(bool& isPrimary, BSONObj* info) {
BSONObjBuilder bob;
bob.append("ismaster", 1);
if (auto wireSpec = WireSpec::instance().get(); wireSpec->isInternalClient) {
@@ -593,7 +594,7 @@ bool DBClientBase::isMaster(bool& isMaster, BSONObj* info) {
if (info == nullptr)
info = &o;
bool ok = runCommand("admin", bob.obj(), *info);
- isMaster = info->getField("ismaster").trueValue();
+ isPrimary = info->getField("ismaster").trueValue();
return ok;
}
@@ -629,7 +630,7 @@ list<BSONObj> DBClientBase::getCollectionInfos(const string& db, const BSONObj&
if (runCommand(db,
BSON("listCollections" << 1 << "filter" << filter << "cursor" << BSONObj()),
res,
- QueryOption_SlaveOk)) {
+ QueryOption_SecondaryOk)) {
BSONObj cursorObj = res["cursor"].Obj();
BSONObj collections = cursorObj["firstBatch"].Obj();
BSONObjIterator it(collections);
@@ -675,7 +676,7 @@ vector<BSONObj> DBClientBase::getDatabaseInfos(const BSONObj& filter,
BSONObj cmd = bob.done();
BSONObj res;
- if (runCommand("admin", cmd, res, QueryOption_SlaveOk)) {
+ if (runCommand("admin", cmd, res, QueryOption_SecondaryOk)) {
BSONObj dbs = res["databases"].Obj();
BSONObjIterator it(dbs);
while (it.more()) {
@@ -768,7 +769,7 @@ std::pair<BSONObj, NamespaceString> DBClientBase::findOneByUUID(
BSONObj cmd = cmdBuilder.obj();
- if (runCommand(db, cmd, res, QueryOption_SlaveOk)) {
+ if (runCommand(db, cmd, res, QueryOption_SecondaryOk)) {
BSONObj cursorObj = res.getObjectField("cursor");
BSONObj docs = cursorObj.getObjectField("firstBatch");
BSONObjIterator it(docs);
@@ -855,7 +856,7 @@ unsigned long long DBClientBase::query(std::function<void(DBClientCursorBatchIte
int batchSize,
boost::optional<BSONObj> readConcernObj) {
// mask options
- queryOptions &= (int)(QueryOption_NoCursorTimeout | QueryOption_SlaveOk);
+ queryOptions &= (int)(QueryOption_NoCursorTimeout | QueryOption_SecondaryOk);
unique_ptr<DBClientCursor> c(this->query(
nsOrUuid, query, 0, 0, fieldsToReturn, queryOptions, batchSize, readConcernObj));
diff --git a/src/mongo/client/dbclient_base.h b/src/mongo/client/dbclient_base.h
index a9dbe457a84..b45479772ec 100644
--- a/src/mongo/client/dbclient_base.h
+++ b/src/mongo/client/dbclient_base.h
@@ -175,7 +175,7 @@ public:
/**
* actualServer is set to the actual server where they call went if there was a choice (for
- * example SlaveOk).
+ * example SecondaryOk).
*/
virtual bool call(Message& toSend,
Message& response,
@@ -274,7 +274,7 @@ public:
directly call runCommand.
@param dbname database name. Use "admin" for global administrative commands.
- @param cmd the command object to execute. For example, { ismaster : 1 }
+ @param cmd the command object to execute. For example, { hello : 1 }
@param info the result object the database returns. Typically has { ok : ..., errmsg : ... }
fields set.
@param options see enum QueryOptions - normally not needed to run a command
@@ -376,15 +376,14 @@ public:
static std::string createPasswordDigest(const std::string& username,
const std::string& clearTextPassword);
- /** returns true in isMaster parm if this db is the current master
- of a replica pair.
+ /** returns true in isPrimary param if this db is the current primary of a replica pair.
pass in info for more details e.g.:
- { "ismaster" : 1.0 , "msg" : "not paired" , "ok" : 1.0 }
+ { "isprimary" : 1.0 , "msg" : "not paired" , "ok" : 1.0 }
returns true if command invoked successfully.
*/
- virtual bool isMaster(bool& isMaster, BSONObj* info = nullptr);
+ virtual bool isPrimary(bool& isPrimary, BSONObj* info = nullptr);
/**
Create a new collection in the database. Normally, collection creation is automatic. You
@@ -616,7 +615,7 @@ public:
virtual int getMinWireVersion() = 0;
virtual int getMaxWireVersion() = 0;
- const std::vector<std::string>& getIsMasterSaslMechanisms() const {
+ const std::vector<std::string>& getIsPrimarySaslMechanisms() const {
return _saslMechsForAuth;
}
@@ -783,8 +782,8 @@ protected:
/** if the result of a command is ok*/
bool isOk(const BSONObj&);
- /** if the element contains a not master error */
- bool isNotMasterErrorString(const BSONElement& e);
+ /** if the element contains a not primary error */
+ bool isNotPrimaryErrorString(const BSONElement& e);
BSONObj _countCmd(const NamespaceStringOrUUID nsOrUuid,
const BSONObj& query,
diff --git a/src/mongo/client/dbclient_connection.cpp b/src/mongo/client/dbclient_connection.cpp
index 31e7f5117b8..e9bb962ff2d 100644
--- a/src/mongo/client/dbclient_connection.cpp
+++ b/src/mongo/client/dbclient_connection.cpp
@@ -643,7 +643,8 @@ unsigned long long DBClientConnection::query(std::function<void(DBClientCursorBa
}
// mask options
- queryOptions &= (int)(QueryOption_NoCursorTimeout | QueryOption_SlaveOk | QueryOption_Exhaust);
+ queryOptions &=
+ (int)(QueryOption_NoCursorTimeout | QueryOption_SecondaryOk | QueryOption_Exhaust);
unique_ptr<DBClientCursor> c(this->query(
nsOrUuid, query, 0, 0, fieldsToReturn, queryOptions, batchSize, readConcernObj));
@@ -811,7 +812,7 @@ void DBClientConnection::handleNotMasterResponse(const BSONObj& replyBody,
const BSONElement errorMsgElem = replyBody[errorMsgFieldName];
const BSONElement codeElem = replyBody["code"];
- if (!isNotMasterErrorString(errorMsgElem) &&
+ if (!isNotPrimaryErrorString(errorMsgElem) &&
!ErrorCodes::isNotPrimaryError(ErrorCodes::Error(codeElem.numberInt()))) {
return;
}
diff --git a/src/mongo/client/dbclient_cursor.cpp b/src/mongo/client/dbclient_cursor.cpp
index 32782e4172c..366cd760283 100644
--- a/src/mongo/client/dbclient_cursor.cpp
+++ b/src/mongo/client/dbclient_cursor.cpp
@@ -401,7 +401,7 @@ void DBClientCursor::dataReceived(const Message& reply, bool& retry, string& hos
"Got invalid reply from external server while reading from cursor",
data.atEof());
- _client->checkResponse(batch.objs, false, &retry, &host); // watches for "not master"
+ _client->checkResponse(batch.objs, false, &retry, &host); // watches for "not primary"
if (qr.getResultFlags() & ResultFlag_ShardConfigStale) {
BSONObj error;
@@ -599,7 +599,7 @@ StatusWith<std::unique_ptr<DBClientCursor>> DBClientCursor::fromAggregationReque
if (!client->runCommand(aggRequest.getNamespaceString().db().toString(),
aggRequest.serializeToCommandObj().toBson(),
ret,
- secondaryOk ? QueryOption_SlaveOk : 0)) {
+ secondaryOk ? QueryOption_SecondaryOk : 0)) {
return {ErrorCodes::CommandFailed, ret.toString()};
}
} catch (...) {
diff --git a/src/mongo/client/dbclient_rs.cpp b/src/mongo/client/dbclient_rs.cpp
index c4119e83fb7..f110566f4bf 100644
--- a/src/mongo/client/dbclient_rs.cpp
+++ b/src/mongo/client/dbclient_rs.cpp
@@ -82,7 +82,7 @@ public:
} _populateReadPrefSecOkCmdList;
/**
- * Maximum number of retries to make for auto-retry logic when performing a slave ok operation.
+ * Maximum number of retries to make for auto-retry logic when performing a secondary ok operation.
*/
const size_t MAX_RETRY = 3;
@@ -107,8 +107,8 @@ const size_t MAX_RETRY = 3;
* @throws AssertionException if the read preference object is malformed
*/
std::unique_ptr<ReadPreferenceSetting> _extractReadPref(const BSONObj& query, int queryOptions) {
- // Default read pref is primary only or secondary preferred with slaveOK
- const auto defaultReadPref = queryOptions & QueryOption_SlaveOk
+ // Default read pref is primary only or secondary preferred with secondaryOK
+ const auto defaultReadPref = queryOptions & QueryOption_SecondaryOk
? ReadPreference::SecondaryPreferred
: ReadPreference::PrimaryOnly;
@@ -173,30 +173,30 @@ string DBClientReplicaSet::getServerAddress() const {
}
HostAndPort DBClientReplicaSet::getSuspectedPrimaryHostAndPort() const {
- if (!_master) {
+ if (!_primary) {
return HostAndPort();
}
- return _master->getServerHostAndPort();
+ return _primary->getServerHostAndPort();
}
void DBClientReplicaSet::setRequestMetadataWriter(rpc::RequestMetadataWriter writer) {
// Set the hooks in both our sub-connections and in ourselves.
- if (_master) {
- _master->setRequestMetadataWriter(writer);
+ if (_primary) {
+ _primary->setRequestMetadataWriter(writer);
}
- if (_lastSlaveOkConn.get()) {
- _lastSlaveOkConn->setRequestMetadataWriter(writer);
+ if (_lastSecondaryOkConn.get()) {
+ _lastSecondaryOkConn->setRequestMetadataWriter(writer);
}
DBClientBase::setRequestMetadataWriter(std::move(writer));
}
void DBClientReplicaSet::setReplyMetadataReader(rpc::ReplyMetadataReader reader) {
// Set the hooks in both our sub-connections and in ourselves.
- if (_master) {
- _master->setReplyMetadataReader(reader);
+ if (_primary) {
+ _primary->setReplyMetadataReader(reader);
}
- if (_lastSlaveOkConn.get()) {
- _lastSlaveOkConn->setReplyMetadataReader(reader);
+ if (_lastSecondaryOkConn.get()) {
+ _lastSecondaryOkConn->setReplyMetadataReader(reader);
}
DBClientBase::setReplyMetadataReader(std::move(reader));
}
@@ -215,13 +215,13 @@ int DBClientReplicaSet::getMaxWireVersion() {
// Has the side effect of proactively clearing any cached connections which have been
// disconnected in the background.
bool DBClientReplicaSet::isStillConnected() {
- if (_master && !_master->isStillConnected()) {
- resetMaster();
+ if (_primary && !_primary->isStillConnected()) {
+ resetPrimary();
// Don't notify monitor of bg failure, since it's not clear how long ago it happened
}
- if (_lastSlaveOkConn.get() && !_lastSlaveOkConn->isStillConnected()) {
- resetSlaveOkConn();
+ if (_lastSecondaryOkConn.get() && !_lastSecondaryOkConn->isStillConnected()) {
+ resetSecondaryOkConn();
// Don't notify monitor of bg failure, since it's not clear how long ago it happened
}
@@ -285,23 +285,23 @@ bool DBClientReplicaSet::isSecondaryQuery(const string& ns,
return _isSecondaryQuery(ns, queryObj, *readPref);
}
-DBClientConnection* DBClientReplicaSet::checkMaster() {
+DBClientConnection* DBClientReplicaSet::checkPrimary() {
ReplicaSetMonitorPtr monitor = _getMonitor();
- HostAndPort h = monitor->getMasterOrUassert();
+ HostAndPort h = monitor->getPrimaryOrUassert();
- if (h == _masterHost && _master) {
- // a master is selected. let's just make sure connection didn't die
- if (!_master->isFailed())
- return _master.get();
+ if (h == _primaryHost && _primary) {
+ // a primary is selected. let's just make sure connection didn't die
+ if (!_primary->isFailed())
+ return _primary.get();
- monitor->failedHost(_masterHost,
- {ErrorCodes::Error(40657), "Last known master host cannot be reached"});
- h = monitor->getMasterOrUassert(); // old master failed, try again.
+ monitor->failedHost(
+ _primaryHost, {ErrorCodes::Error(40657), "Last known primary host cannot be reached"});
+ h = monitor->getPrimaryOrUassert(); // old primary failed, try again.
}
- _masterHost = h;
+ _primaryHost = h;
- MongoURI masterUri = _uri.cloneURIForServer(_masterHost, _applicationName);
+ MongoURI primaryUri = _uri.cloneURIForServer(_primaryHost, _applicationName);
string errmsg;
DBClientConnection* newConn = nullptr;
@@ -314,34 +314,34 @@ DBClientConnection* DBClientReplicaSet::checkMaster() {
// callback. We should eventually not need this after we remove the
// callback.
newConn = dynamic_cast<DBClientConnection*>(
- masterUri.connect(_applicationName, errmsg, socketTimeout));
+ primaryUri.connect(_applicationName, errmsg, socketTimeout));
} catch (const AssertionException& ex) {
errmsg = ex.toString();
}
if (newConn == nullptr || !errmsg.empty()) {
const std::string message = str::stream()
- << "can't connect to new replica set master [" << _masterHost.toString() << "]"
+ << "can't connect to new replica set primary [" << _primaryHost.toString() << "]"
<< (errmsg.empty() ? "" : ", err: ") << errmsg;
- monitor->failedHost(_masterHost, {ErrorCodes::Error(40659), message});
+ monitor->failedHost(_primaryHost, {ErrorCodes::Error(40659), message});
uasserted(ErrorCodes::FailedToSatisfyReadPreference, message);
}
- resetMaster();
+ resetPrimary();
- _masterHost = h;
- _master.reset(newConn);
- _master->setParentReplSetName(_setName);
- _master->setRequestMetadataWriter(getRequestMetadataWriter());
- _master->setReplyMetadataReader(getReplyMetadataReader());
+ _primaryHost = h;
+ _primary.reset(newConn);
+ _primary->setParentReplSetName(_setName);
+ _primary->setRequestMetadataWriter(getRequestMetadataWriter());
+ _primary->setReplyMetadataReader(getReplyMetadataReader());
- _authConnection(_master.get());
- return _master.get();
+ _authConnection(_primary.get());
+ return _primary.get();
}
bool DBClientReplicaSet::checkLastHost(const ReadPreferenceSetting* readPref) {
// Can't use a cached host if we don't have one.
- if (!_lastSlaveOkConn.get() || _lastSlaveOkHost.empty()) {
+ if (!_lastSecondaryOkConn.get() || _lastSecondaryOkHost.empty()) {
return false;
}
@@ -351,9 +351,9 @@ bool DBClientReplicaSet::checkLastHost(const ReadPreferenceSetting* readPref) {
}
// Make sure we don't think the host is down.
- if (_lastSlaveOkConn->isFailed() || !_getMonitor()->isHostUp(_lastSlaveOkHost)) {
- _invalidateLastSlaveOkCache(
- {ErrorCodes::Error(40660), "Last slave connection is no longer available"});
+ if (_lastSecondaryOkConn->isFailed() || !_getMonitor()->isHostUp(_lastSecondaryOkHost)) {
+ _invalidateLastSecondaryOkCache(
+ {ErrorCodes::Error(40660), "Last secondary connection is no longer available"});
return false;
}
@@ -404,11 +404,11 @@ void DBClientReplicaSet::logoutAll(DBClientConnection* conn) {
}
}
-DBClientConnection& DBClientReplicaSet::masterConn() {
- return *checkMaster();
+DBClientConnection& DBClientReplicaSet::primaryConn() {
+ return *checkPrimary();
}
-DBClientConnection& DBClientReplicaSet::slaveConn() {
+DBClientConnection& DBClientReplicaSet::secondaryConn() {
shared_ptr<ReadPreferenceSetting> readPref(
new ReadPreferenceSetting(ReadPreference::SecondaryPreferred, TagSet()));
DBClientConnection* conn = selectNodeUsingTags(readPref);
@@ -453,13 +453,13 @@ Status DBClientReplicaSet::_runAuthLoop(Authenticate authCb) {
// Ensure the only child connection open is the one we authenticated against - other
// child connections may not have full authentication information.
- // NOTE: _lastSlaveOkConn may or may not be the same as _master
- dassert(_lastSlaveOkConn.get() == conn || _master.get() == conn);
- if (conn != _lastSlaveOkConn.get()) {
- resetSlaveOkConn();
+ // NOTE: _lastSecondaryOkConn may or may not be the same as _primary
+ dassert(_lastSecondaryOkConn.get() == conn || _primary.get() == conn);
+ if (conn != _lastSecondaryOkConn.get()) {
+ resetSecondaryOkConn();
}
- if (conn != _master.get()) {
- resetMaster();
+ if (conn != _primary.get()) {
+ resetPrimary();
}
return Status::OK();
@@ -471,8 +471,8 @@ Status DBClientReplicaSet::_runAuthLoop(Authenticate authCb) {
lastNodeStatus =
status.withContext(str::stream() << "can't authenticate against replica set node "
- << _lastSlaveOkHost);
- _invalidateLastSlaveOkCache(lastNodeStatus);
+ << _lastSecondaryOkHost);
+ _invalidateLastSecondaryOkCache(lastNodeStatus);
}
}
@@ -506,7 +506,7 @@ void DBClientReplicaSet::_auth(const BSONObj& params) {
}
void DBClientReplicaSet::logout(const string& dbname, BSONObj& info) {
- DBClientConnection* priConn = checkMaster();
+ DBClientConnection* priConn = checkPrimary();
priConn->logout(dbname, info);
_auths.erase(dbname);
@@ -515,13 +515,13 @@ void DBClientReplicaSet::logout(const string& dbname, BSONObj& info) {
* needed when we actually have something cached and is last known to be
* working.
*/
- if (_lastSlaveOkConn.get() != nullptr && !_lastSlaveOkConn->isFailed()) {
+ if (_lastSecondaryOkConn.get() != nullptr && !_lastSecondaryOkConn->isFailed()) {
try {
BSONObj dummy;
- _lastSlaveOkConn->logout(dbname, dummy);
+ _lastSecondaryOkConn->logout(dbname, dummy);
} catch (const DBException&) {
// Make sure we can't use this connection again.
- verify(_lastSlaveOkConn->isFailed());
+ verify(_lastSecondaryOkConn->isFailed());
}
}
}
@@ -532,21 +532,21 @@ void DBClientReplicaSet::insert(const string& ns,
BSONObj obj,
int flags,
boost::optional<BSONObj> writeConcernObj) {
- checkMaster()->insert(ns, obj, flags, writeConcernObj);
+ checkPrimary()->insert(ns, obj, flags, writeConcernObj);
}
void DBClientReplicaSet::insert(const string& ns,
const vector<BSONObj>& v,
int flags,
boost::optional<BSONObj> writeConcernObj) {
- checkMaster()->insert(ns, v, flags, writeConcernObj);
+ checkPrimary()->insert(ns, v, flags, writeConcernObj);
}
void DBClientReplicaSet::remove(const string& ns,
Query obj,
int flags,
boost::optional<BSONObj> writeConcernObj) {
- checkMaster()->remove(ns, obj, flags, writeConcernObj);
+ checkPrimary()->remove(ns, obj, flags, writeConcernObj);
}
void DBClientReplicaSet::update(const string& ns,
@@ -554,7 +554,7 @@ void DBClientReplicaSet::update(const string& ns,
BSONObj obj,
int flags,
boost::optional<BSONObj> writeConcernObj) {
- return checkMaster()->update(ns, query, obj, flags, writeConcernObj);
+ return checkPrimary()->update(ns, query, obj, flags, writeConcernObj);
}
unique_ptr<DBClientCursor> DBClientReplicaSet::query(const NamespaceStringOrUUID& nsOrUuid,
@@ -578,10 +578,10 @@ unique_ptr<DBClientCursor> DBClientReplicaSet::query(const NamespaceStringOrUUID
"replicaSet"_attr = _getMonitor()->getName(),
"readPref"_attr = readPref->toString(),
"primary"_attr =
- (_master.get() != nullptr ? _master->getServerAddress() : "[not cached]"),
- "lastTagged"_attr =
- (_lastSlaveOkConn.get() != nullptr ? _lastSlaveOkConn->getServerAddress()
- : "[not cached]"));
+ (_primary.get() != nullptr ? _primary->getServerAddress() : "[not cached]"),
+ "lastTagged"_attr = (_lastSecondaryOkConn.get() != nullptr
+ ? _lastSecondaryOkConn->getServerAddress()
+ : "[not cached]"));
string lastNodeErrMsg;
@@ -602,12 +602,12 @@ unique_ptr<DBClientCursor> DBClientReplicaSet::query(const NamespaceStringOrUUID
batchSize,
readConcernObj);
- return checkSlaveQueryResult(std::move(cursor));
+ return checkSecondaryQueryResult(std::move(cursor));
} catch (const DBException& ex) {
const Status status = ex.toStatus(str::stream() << "can't query replica set node "
- << _lastSlaveOkHost);
+ << _lastSecondaryOkHost);
lastNodeErrMsg = status.reason();
- _invalidateLastSlaveOkCache(status);
+ _invalidateLastSecondaryOkCache(status);
}
}
@@ -626,14 +626,14 @@ unique_ptr<DBClientCursor> DBClientReplicaSet::query(const NamespaceStringOrUUID
"dbclient_rs query to primary node",
"replicaSet"_attr = _getMonitor()->getName());
- return checkMaster()->query(nsOrUuid,
- query,
- nToReturn,
- nToSkip,
- fieldsToReturn,
- queryOptions,
- batchSize,
- readConcernObj);
+ return checkPrimary()->query(nsOrUuid,
+ query,
+ nToReturn,
+ nToSkip,
+ fieldsToReturn,
+ queryOptions,
+ batchSize,
+ readConcernObj);
}
BSONObj DBClientReplicaSet::findOne(const string& ns,
@@ -652,10 +652,10 @@ BSONObj DBClientReplicaSet::findOne(const string& ns,
"replicaSet"_attr = _getMonitor()->getName(),
"readPref"_attr = readPref->toString(),
"primary"_attr =
- (_master.get() != nullptr ? _master->getServerAddress() : "[not cached]"),
- "secondaryHostNamme"_attr =
- (_lastSlaveOkConn.get() != nullptr ? _lastSlaveOkConn->getServerAddress()
- : "[not cached]"));
+ (_primary.get() != nullptr ? _primary->getServerAddress() : "[not cached]"),
+ "secondaryHostNamme"_attr = (_lastSecondaryOkConn.get() != nullptr
+ ? _lastSecondaryOkConn->getServerAddress()
+ : "[not cached]"));
string lastNodeErrMsg;
@@ -670,9 +670,9 @@ BSONObj DBClientReplicaSet::findOne(const string& ns,
return conn->findOne(ns, query, fieldsToReturn, queryOptions, readConcernObj);
} catch (const DBException& ex) {
const Status status = ex.toStatus(str::stream() << "can't findone replica set node "
- << _lastSlaveOkHost.toString());
+ << _lastSecondaryOkHost.toString());
lastNodeErrMsg = status.reason();
- _invalidateLastSlaveOkCache(status);
+ _invalidateLastSecondaryOkCache(status);
}
}
@@ -691,28 +691,28 @@ BSONObj DBClientReplicaSet::findOne(const string& ns,
"dbclient_rs findOne to primary node",
"replicaSet"_attr = _getMonitor()->getName());
- return checkMaster()->findOne(ns, query, fieldsToReturn, queryOptions, readConcernObj);
+ return checkPrimary()->findOne(ns, query, fieldsToReturn, queryOptions, readConcernObj);
}
void DBClientReplicaSet::killCursor(const NamespaceString& ns, long long cursorID) {
// we should never call killCursor on a replica set connection
// since we don't know which server it belongs to
- // can't assume master because of slave ok
- // and can have a cursor survive a master change
+ // can't assume primary because of secondary ok
+ // and can have a cursor survive a primary change
verify(0);
}
-void DBClientReplicaSet::isntMaster() {
+void DBClientReplicaSet::isNotPrimary() {
// Can't use _getMonitor because that will create a new monitor from the cached seed if the
// monitor doesn't exist.
_rsm->failedHost(
- _masterHost,
- {ErrorCodes::NotWritablePrimary, str::stream() << "got not master for: " << _masterHost});
+ _primaryHost,
+ {ErrorCodes::NotWritablePrimary, str::stream() << "got not primary for: " << _primaryHost});
- resetMaster();
+ resetPrimary();
}
-unique_ptr<DBClientCursor> DBClientReplicaSet::checkSlaveQueryResult(
+unique_ptr<DBClientCursor> DBClientReplicaSet::checkSecondaryQueryResult(
unique_ptr<DBClientCursor> result) {
if (result.get() == nullptr)
return result;
@@ -729,7 +729,7 @@ unique_ptr<DBClientCursor> DBClientReplicaSet::checkSlaveQueryResult(
if (code.isNumber() && code.Int() == ErrorCodes::NotPrimaryOrSecondary) {
isntSecondary();
uasserted(14812,
- str::stream() << "slave " << _lastSlaveOkHost.toString()
+ str::stream() << "secondary " << _lastSecondaryOkHost.toString()
<< " is no longer secondary");
}
@@ -739,11 +739,11 @@ unique_ptr<DBClientCursor> DBClientReplicaSet::checkSlaveQueryResult(
void DBClientReplicaSet::isntSecondary() {
// Failover to next secondary
_getMonitor()->failedHost(
- _lastSlaveOkHost,
+ _lastSecondaryOkHost,
{ErrorCodes::NotPrimaryOrSecondary,
- str::stream() << "slave no longer has secondary status: " << _lastSlaveOkHost});
+ str::stream() << "secondary no longer has secondary status: " << _lastSecondaryOkHost});
- resetSlaveOkConn();
+ resetSecondaryOkConn();
}
DBClientConnection* DBClientReplicaSet::selectNodeUsingTags(
@@ -753,9 +753,9 @@ DBClientConnection* DBClientReplicaSet::selectNodeUsingTags(
3,
"dbclient_rs selecting compatible last used node {lastTagged}",
"dbclient_rs selecting compatible last used node",
- "lastTagged"_attr = _lastSlaveOkHost);
+ "lastTagged"_attr = _lastSecondaryOkHost);
- return _lastSlaveOkConn.get();
+ return _lastSecondaryOkConn.get();
}
ReplicaSetMonitorPtr monitor = _getMonitor();
@@ -774,17 +774,17 @@ DBClientConnection* DBClientReplicaSet::selectNodeUsingTags(
// We are now about to get a new connection from the pool, so cleanup
// the current one and release it back to the pool.
- resetSlaveOkConn();
+ resetSecondaryOkConn();
_lastReadPref = readPref;
- _lastSlaveOkHost = selectedNode;
+ _lastSecondaryOkHost = selectedNode;
// Primary connection is special because it is the only connection that is
// versioned in mongos. Therefore, we have to make sure that this object
// maintains only one connection to the primary and use that connection
// every time we need to talk to the primary.
if (monitor->isPrimary(selectedNode)) {
- checkMaster();
+ checkPrimary();
LOGV2_DEBUG(20139,
3,
@@ -792,12 +792,12 @@ DBClientConnection* DBClientReplicaSet::selectNodeUsingTags(
"dbclient_rs selecting primary node",
"connString"_attr = selectedNode);
- _lastSlaveOkConn = _master;
+ _lastSecondaryOkConn = _primary;
- return _master.get();
+ return _primary.get();
}
- auto dtor = [host = _lastSlaveOkHost.toString()](DBClientConnection* ptr) {
+ auto dtor = [host = _lastSecondaryOkHost.toString()](DBClientConnection* ptr) {
globalConnPool.release(host, ptr);
};
@@ -805,22 +805,22 @@ DBClientConnection* DBClientReplicaSet::selectNodeUsingTags(
// callback. We should eventually not need this after we remove the
// callback.
DBClientConnection* newConn = dynamic_cast<DBClientConnection*>(globalConnPool.get(
- _uri.cloneURIForServer(_lastSlaveOkHost, _applicationName), _so_timeout));
+ _uri.cloneURIForServer(_lastSecondaryOkHost, _applicationName), _so_timeout));
// Assert here instead of returning NULL since the contract of this method is such
// that returning NULL means none of the nodes were good, which is not the case here.
uassert(16532,
- str::stream() << "Failed to connect to " << _lastSlaveOkHost.toString(),
+ str::stream() << "Failed to connect to " << _lastSecondaryOkHost.toString(),
newConn != nullptr);
- _lastSlaveOkConn = std::shared_ptr<DBClientConnection>(newConn, std::move(dtor));
- _lastSlaveOkConn->setParentReplSetName(_setName);
- _lastSlaveOkConn->setRequestMetadataWriter(getRequestMetadataWriter());
- _lastSlaveOkConn->setReplyMetadataReader(getReplyMetadataReader());
+ _lastSecondaryOkConn = std::shared_ptr<DBClientConnection>(newConn, std::move(dtor));
+ _lastSecondaryOkConn->setParentReplSetName(_setName);
+ _lastSecondaryOkConn->setRequestMetadataWriter(getRequestMetadataWriter());
+ _lastSecondaryOkConn->setReplyMetadataReader(getReplyMetadataReader());
if (_authPooledSecondaryConn) {
- if (!_lastSlaveOkConn->authenticatedDuringConnect()) {
- _authConnection(_lastSlaveOkConn.get());
+ if (!_lastSecondaryOkConn->authenticatedDuringConnect()) {
+ _authConnection(_lastSecondaryOkConn.get());
}
}
@@ -828,9 +828,9 @@ DBClientConnection* DBClientReplicaSet::selectNodeUsingTags(
3,
"dbclient_rs selecting node {connString}",
"dbclient_rs selecting node",
- "connString"_attr = _lastSlaveOkHost);
+ "connString"_attr = _lastSecondaryOkHost);
- return _lastSlaveOkConn.get();
+ return _lastSecondaryOkConn.get();
}
void DBClientReplicaSet::say(Message& toSend, bool isRetry, string* actualServer) {
@@ -854,10 +854,10 @@ void DBClientReplicaSet::say(Message& toSend, bool isRetry, string* actualServer
"dbclient_rs say using secondary or tagged node selection",
"replicaSet"_attr = _getMonitor()->getName(),
"readPref"_attr = readPref->toString(),
- "primary"_attr = (_master.get() != nullptr ? _master->getServerAddress()
- : "[not cached]"),
- "lastTagged"_attr = (_lastSlaveOkConn.get() != nullptr
- ? _lastSlaveOkConn->getServerAddress()
+ "primary"_attr = (_primary.get() != nullptr ? _primary->getServerAddress()
+ : "[not cached]"),
+ "lastTagged"_attr = (_lastSecondaryOkConn.get() != nullptr
+ ? _lastSecondaryOkConn->getServerAddress()
: "[not cached]"));
string lastNodeErrMsg;
@@ -883,9 +883,9 @@ void DBClientReplicaSet::say(Message& toSend, bool isRetry, string* actualServer
} catch (const DBException& ex) {
const Status status =
ex.toStatus(str::stream() << "can't callLazy replica set node "
- << _lastSlaveOkHost.toString());
+ << _lastSecondaryOkHost.toString());
lastNodeErrMsg = status.reason();
- _invalidateLastSlaveOkCache(status);
+ _invalidateLastSecondaryOkCache(status);
continue;
}
@@ -909,17 +909,17 @@ void DBClientReplicaSet::say(Message& toSend, bool isRetry, string* actualServer
"dbclient_rs say to primary node",
"replicaSet"_attr = _getMonitor()->getName());
- DBClientConnection* master = checkMaster();
+ DBClientConnection* primary = checkPrimary();
if (actualServer)
- *actualServer = master->getServerAddress();
+ *actualServer = primary->getServerAddress();
_lazyState._lastOp = lastOp;
_lazyState._secondaryQueryOk = false;
// Don't retry requests to primary since there is only one host to try
_lazyState._retries = MAX_RETRY;
- _lazyState._lastClient = master;
+ _lazyState._lastClient = primary;
- master->say(toSend);
+ primary->say(toSend);
return;
}
@@ -948,7 +948,7 @@ void DBClientReplicaSet::checkResponse(const std::vector<BSONObj>& batch,
if (_lazyState._lastClient)
return _lazyState._lastClient->checkResponse(batch, networkError);
else
- return checkMaster()->checkResponse(batch, networkError);
+ return checkPrimary()->checkResponse(batch, networkError);
}
*retry = false;
@@ -978,15 +978,15 @@ void DBClientReplicaSet::checkResponse(const std::vector<BSONObj>& batch,
if (networkError ||
(hasErrField(dataObj) && !dataObj["code"].eoo() &&
dataObj["code"].Int() == ErrorCodes::NotPrimaryOrSecondary)) {
- if (_lazyState._lastClient == _lastSlaveOkConn.get()) {
+ if (_lazyState._lastClient == _lastSecondaryOkConn.get()) {
isntSecondary();
- } else if (_lazyState._lastClient == _master.get()) {
- isntMaster();
+ } else if (_lazyState._lastClient == _primary.get()) {
+ isNotPrimary();
} else {
LOGV2_WARNING(20151,
"Data {dataObj} is invalid because last rs client {connString} is "
- "not master or secondary",
- "Data is invalid because last rs client is not master or secondary",
+ "not primary or secondary",
+ "Data is invalid because last rs client is not primary or secondary",
"dataObj"_attr = redact(dataObj),
"connString"_attr = _lazyState._lastClient->toString());
}
@@ -1002,13 +1002,13 @@ void DBClientReplicaSet::checkResponse(const std::vector<BSONObj>& batch,
}
}
} else if (_lazyState._lastOp == dbQuery) {
- // if query could not potentially go to a secondary, just mark the master as bad
+ // if query could not potentially go to a secondary, just mark the primary as bad
if (networkError ||
(hasErrField(dataObj) && !dataObj["code"].eoo() &&
dataObj["code"].Int() == ErrorCodes::NotPrimaryNoSecondaryOk)) {
- if (_lazyState._lastClient == _master.get()) {
- isntMaster();
+ if (_lazyState._lastClient == _primary.get()) {
+ isNotPrimary();
}
}
}
@@ -1018,7 +1018,7 @@ DBClientBase* DBClientReplicaSet::runFireAndForgetCommand(OpMsgRequest request)
// Assume all fire-and-forget commands should go to the primary node. It is currently used
// for writes which need to go to the primary and for killCursors which should be sent to a
// specific host rather than through DBClientReplicaSet.
- return checkMaster()->runFireAndForgetCommand(std::move(request));
+ return checkPrimary()->runFireAndForgetCommand(std::move(request));
}
std::pair<rpc::UniqueReply, DBClientBase*> DBClientReplicaSet::runCommandWithTarget(
@@ -1036,7 +1036,7 @@ std::pair<rpc::UniqueReply, DBClientBase*> DBClientReplicaSet::runCommandWithTar
// If the command is not runnable on a secondary, we run it on the primary
// regardless of the read preference.
!_isSecondaryCommand(request.getCommandName(), request.body)) {
- auto conn = checkMaster();
+ auto conn = checkPrimary();
return conn->runCommandWithTarget(std::move(request));
}
@@ -1051,7 +1051,7 @@ std::pair<rpc::UniqueReply, DBClientBase*> DBClientReplicaSet::runCommandWithTar
// We can't move the request since we need it to retry.
return conn->runCommandWithTarget(request);
} catch (const DBException& ex) {
- _invalidateLastSlaveOkCache(ex.toStatus());
+ _invalidateLastSecondaryOkCache(ex.toStatus());
}
}
@@ -1066,12 +1066,12 @@ std::pair<rpc::UniqueReply, std::shared_ptr<DBClientBase>> DBClientReplicaSet::r
auto out = runCommandWithTarget(std::move(request));
std::shared_ptr<DBClientBase> conn = [&] {
- if (out.second == _lastSlaveOkConn.get()) {
- return _lastSlaveOkConn;
+ if (out.second == _lastSecondaryOkConn.get()) {
+ return _lastSecondaryOkConn;
}
- if (out.second == _master.get()) {
- return _master;
+ if (out.second == _primary.get()) {
+ return _primary;
}
MONGO_UNREACHABLE;
@@ -1104,10 +1104,10 @@ bool DBClientReplicaSet::call(Message& toSend,
"replicaSet"_attr = _getMonitor()->getName(),
"readPref"_attr = readPref->toString(),
"primary"_attr =
- (_master.get() != nullptr ? _master->getServerAddress() : "[not cached]"),
- "lastTagged"_attr =
- (_lastSlaveOkConn.get() != nullptr ? _lastSlaveOkConn->getServerAddress()
- : "[not cached]"));
+ (_primary.get() != nullptr ? _primary->getServerAddress() : "[not cached]"),
+ "lastTagged"_attr = (_lastSecondaryOkConn.get() != nullptr
+ ? _lastSecondaryOkConn->getServerAddress()
+ : "[not cached]"));
for (size_t retry = 0; retry < MAX_RETRY; retry++) {
try {
@@ -1127,8 +1127,8 @@ bool DBClientReplicaSet::call(Message& toSend,
*actualServer = "";
const Status status = ex.toStatus();
- _invalidateLastSlaveOkCache(status.withContext(
- str::stream() << "can't call replica set node " << _lastSlaveOkHost));
+ _invalidateLastSecondaryOkCache(status.withContext(
+ str::stream() << "can't call replica set node " << _lastSecondaryOkHost));
}
}
@@ -1143,7 +1143,7 @@ bool DBClientReplicaSet::call(Message& toSend,
"dbclient_rs call to primary node",
"replicaSet"_attr = _getMonitor()->getName());
- DBClientConnection* m = checkMaster();
+ DBClientConnection* m = checkPrimary();
if (actualServer)
*actualServer = m->getServerAddress();
@@ -1155,11 +1155,11 @@ bool DBClientReplicaSet::call(Message& toSend,
if (res.getNReturned() == 1) {
BSONObj x(res.data());
if (str::contains(ns, "$cmd")) {
- if (isNotMasterErrorString(x["errmsg"]))
- isntMaster();
+ if (isNotPrimaryErrorString(x["errmsg"]))
+ isNotPrimary();
} else {
- if (isNotMasterErrorString(getErrField(x)))
- isntMaster();
+ if (isNotPrimaryErrorString(getErrField(x)))
+ isNotPrimary();
}
}
}
@@ -1167,16 +1167,16 @@ bool DBClientReplicaSet::call(Message& toSend,
return true;
}
-void DBClientReplicaSet::_invalidateLastSlaveOkCache(const Status& status) {
- // This is not wrapped in with if (_lastSlaveOkConn && _lastSlaveOkConn->isFailed()) because
- // there are certain exceptions that will not make the connection be labeled as failed. For
- // example, asserts 13079, 13080, 16386
- _getMonitor()->failedHost(_lastSlaveOkHost, status);
- resetSlaveOkConn();
+void DBClientReplicaSet::_invalidateLastSecondaryOkCache(const Status& status) {
+ // This is not wrapped in with if (_lastSecondaryOkConn && _lastSecondaryOkConn->isFailed())
+ // because there are certain exceptions that will not make the connection be labeled as failed.
+ // For example, asserts 13079, 13080, 16386
+ _getMonitor()->failedHost(_lastSecondaryOkHost, status);
+ resetSecondaryOkConn();
}
void DBClientReplicaSet::reset() {
- resetSlaveOkConn();
+ resetSecondaryOkConn();
_lazyState._lastClient = nullptr;
_lastReadPref.reset();
}
@@ -1185,36 +1185,36 @@ void DBClientReplicaSet::setAuthPooledSecondaryConn(bool setting) {
_authPooledSecondaryConn = setting;
}
-void DBClientReplicaSet::resetMaster() {
- if (_master.get() == _lastSlaveOkConn.get()) {
- _lastSlaveOkConn.reset();
- _lastSlaveOkHost = HostAndPort();
+void DBClientReplicaSet::resetPrimary() {
+ if (_primary.get() == _lastSecondaryOkConn.get()) {
+ _lastSecondaryOkConn.reset();
+ _lastSecondaryOkHost = HostAndPort();
}
- _master.reset();
- _masterHost = HostAndPort();
+ _primary.reset();
+ _primaryHost = HostAndPort();
}
-void DBClientReplicaSet::resetSlaveOkConn() {
- if (_lastSlaveOkConn.get() == _master.get()) {
- _lastSlaveOkConn.reset();
- } else if (_lastSlaveOkConn.get() != nullptr) {
+void DBClientReplicaSet::resetSecondaryOkConn() {
+ if (_lastSecondaryOkConn.get() == _primary.get()) {
+ _lastSecondaryOkConn.reset();
+ } else if (_lastSecondaryOkConn.get() != nullptr) {
if (_authPooledSecondaryConn) {
- logoutAll(_lastSlaveOkConn.get());
+ logoutAll(_lastSecondaryOkConn.get());
} else {
// Mongos pooled connections are all authenticated with the same credentials;
// so no need to logout.
}
- _lastSlaveOkConn.reset();
+ _lastSecondaryOkConn.reset();
}
- _lastSlaveOkHost = HostAndPort();
+ _lastSecondaryOkHost = HostAndPort();
}
#ifdef MONGO_CONFIG_SSL
const SSLConfiguration* DBClientReplicaSet::getSSLConfiguration() {
- return checkMaster()->getSSLConfiguration();
+ return checkPrimary()->getSSLConfiguration();
}
#endif
diff --git a/src/mongo/client/dbclient_rs.h b/src/mongo/client/dbclient_rs.h
index e86cac71ae9..64a9ddffb03 100644
--- a/src/mongo/client/dbclient_rs.h
+++ b/src/mongo/client/dbclient_rs.h
@@ -48,7 +48,7 @@ struct ReadPreferenceSetting;
typedef std::shared_ptr<ReplicaSetMonitor> ReplicaSetMonitorPtr;
/** Use this class to connect to a replica set of servers. The class will manage
- checking for which server in a replica set is master, and do failover automatically.
+ checking for which server in a replica set is primary, and do failover automatically.
This can also be used to connect to replica pairs since pairs are a subset of sets
@@ -90,7 +90,7 @@ public:
// ----------- simple functions --------------
- /** throws userassertion "no master found" */
+ /** throws userassertion "no primary found" */
std::unique_ptr<DBClientCursor> query(
const NamespaceStringOrUUID& nsOrUuid,
Query query,
@@ -101,7 +101,7 @@ public:
int batchSize = 0,
boost::optional<BSONObj> readConcernObj = boost::none) override;
- /** throws userassertion "no master found" */
+ /** throws userassertion "no primary found" */
BSONObj findOne(const std::string& ns,
const Query& query,
const BSONObj* fieldsToReturn = nullptr,
@@ -137,20 +137,20 @@ public:
/**
* WARNING: this method is very dangerous - this object can decide to free the
- * returned master connection any time.
+ * returned primary connection any time.
*
- * @return the reference to the address that points to the master connection.
+ * @return the reference to the address that points to the primary connection.
*/
- DBClientConnection& masterConn();
+ DBClientConnection& primaryConn();
/**
* WARNING: this method is very dangerous - this object can decide to free the
- * returned master connection any time. This can also unpin the cached
- * slaveOk/read preference connection.
+ * returned primary connection any time. This can also unpin the cached
+ * secondaryOk/read preference connection.
*
* @return the reference to the address that points to a secondary connection.
*/
- DBClientConnection& slaveConn();
+ DBClientConnection& secondaryConn();
// ---- callback pieces -------
@@ -161,19 +161,19 @@ public:
bool* retry = nullptr,
std::string* targetHost = nullptr) override;
- /* this is the callback from our underlying connections to notify us that we got a "not master"
+ /* this is the callback from our underlying connections to notify us that we got a "not primary"
* error.
*/
- void isntMaster();
+ void isNotPrimary();
- /* this is used to indicate we got a "not master or secondary" error from a secondary.
+ /* this is used to indicate we got a "not primary or secondary" error from a secondary.
*/
void isntSecondary();
// ----- status ------
bool isFailed() const override {
- return !_master || _master->isFailed();
+ return !_primary || _primary->isFailed();
}
bool isStillConnected() override;
@@ -271,15 +271,16 @@ protected:
private:
/**
- * Used to simplify slave-handling logic on errors
+ * Used to simplify secondary-handling logic on errors
*
* @return back the passed cursor
* @throws DBException if the directed node cannot accept the query because it
- * is not a master
+ * is not a primary
*/
- std::unique_ptr<DBClientCursor> checkSlaveQueryResult(std::unique_ptr<DBClientCursor> result);
+ std::unique_ptr<DBClientCursor> checkSecondaryQueryResult(
+ std::unique_ptr<DBClientCursor> result);
- DBClientConnection* checkMaster();
+ DBClientConnection* checkPrimary();
template <typename Authenticate>
Status _runAuthLoop(Authenticate authCb);
@@ -299,16 +300,16 @@ private:
DBClientConnection* selectNodeUsingTags(std::shared_ptr<ReadPreferenceSetting> readPref);
/**
- * @return true if the last host used in the last slaveOk query is still in the
+ * @return true if the last host used in the last secondaryOk query is still in the
* set and can be used for the given read preference.
*/
bool checkLastHost(const ReadPreferenceSetting* readPref);
/**
- * Destroys all cached information about the last slaveOk operation and reports the host as
+ * Destroys all cached information about the last secondaryOk operation and reports the host as
* failed in the replica set monitor with the specified 'status'.
*/
- void _invalidateLastSlaveOkCache(const Status& status);
+ void _invalidateLastSecondaryOkCache(const Status& status);
void _authConnection(DBClientConnection* conn);
@@ -319,14 +320,14 @@ private:
void logoutAll(DBClientConnection* conn);
/**
- * Clears the master connection.
+ * Clears the primary connection.
*/
- void resetMaster();
+ void resetPrimary();
/**
- * Clears the slaveOk connection and returns it to the pool if not the same as _master.
+ * Clears the secondaryOk connection and returns it to the pool if not the same as _primary.
*/
- void resetSlaveOkConn();
+ void resetSecondaryOkConn();
// TODO: remove this when processes other than mongos uses the driver version.
static bool _authPooledSecondaryConn;
@@ -338,16 +339,16 @@ private:
std::string _applicationName;
std::shared_ptr<ReplicaSetMonitor> _rsm;
- HostAndPort _masterHost;
- std::shared_ptr<DBClientConnection> _master;
+ HostAndPort _primaryHost;
+ std::shared_ptr<DBClientConnection> _primary;
- // Last used host in a slaveOk query (can be a primary).
- HostAndPort _lastSlaveOkHost;
- // Last used connection in a slaveOk query (can be a primary).
+ // Last used host in a secondaryOk query (can be a primary).
+ HostAndPort _lastSecondaryOkHost;
+ // Last used connection in a secondaryOk query (can be a primary).
// Connection can either be owned here or returned to the connection pool. Note that
- // if connection is primary, it is owned by _master so it is incorrect to return
+ // if connection is primary, it is owned by _primary so it is incorrect to return
// it to the pool.
- std::shared_ptr<DBClientConnection> _lastSlaveOkConn;
+ std::shared_ptr<DBClientConnection> _lastSecondaryOkConn;
std::shared_ptr<ReadPreferenceSetting> _lastReadPref;
double _so_timeout;
diff --git a/src/mongo/client/dbclient_rs_test.cpp b/src/mongo/client/dbclient_rs_test.cpp
index 991a96f215f..3765148e8ff 100644
--- a/src/mongo/client/dbclient_rs_test.cpp
+++ b/src/mongo/client/dbclient_rs_test.cpp
@@ -809,20 +809,20 @@ TEST_F(TaggedFiveMemberRS, ConnShouldNotPinIfDiffTag) {
}
}
-// Note: slaveConn is dangerous and should be deprecated! Also see SERVER-7801.
-TEST_F(TaggedFiveMemberRS, SlaveConnReturnsSecConn) {
+// Note: secondaryConn is dangerous and should be deprecated! Also see SERVER-7801.
+TEST_F(TaggedFiveMemberRS, SecondaryConnReturnsSecConn) {
MockReplicaSet* replSet = getReplSet();
vector<HostAndPort> seedList;
seedList.push_back(HostAndPort(replSet->getPrimary()));
DBClientReplicaSet replConn(replSet->getSetName(), seedList, StringData());
- // Need up-to-date view since slaveConn() uses SecondaryPreferred, and this test assumes it
+ // Need up-to-date view since secondaryConn() uses SecondaryPreferred, and this test assumes it
// knows about at least one secondary.
ReplicaSetMonitor::get(replSet->getSetName())->runScanForMockReplicaSet();
string dest;
- mongo::DBClientConnection& secConn = replConn.slaveConn();
+ mongo::DBClientConnection& secConn = replConn.secondaryConn();
// Note: IdentityNS contains the name of the server.
unique_ptr<DBClientCursor> cursor = secConn.query(NamespaceString(IdentityNS), Query());
diff --git a/src/mongo/client/mongo_uri_connect.cpp b/src/mongo/client/mongo_uri_connect.cpp
index 34144bc0b66..fc11a7eb9ce 100644
--- a/src/mongo/client/mongo_uri_connect.cpp
+++ b/src/mongo/client/mongo_uri_connect.cpp
@@ -65,7 +65,7 @@ DBClientBase* MongoURI::connect(StringData applicationName,
if (!ret->authenticatedDuringConnect()) {
auto optAuthObj =
- makeAuthObjFromOptions(ret->getMaxWireVersion(), ret->getIsMasterSaslMechanisms());
+ makeAuthObjFromOptions(ret->getMaxWireVersion(), ret->getIsPrimarySaslMechanisms());
if (optAuthObj) {
ret->auth(optAuthObj.get());
}
diff --git a/src/mongo/client/replica_set_monitor_interface.h b/src/mongo/client/replica_set_monitor_interface.h
index ad40412dbc4..741f2e30af4 100644
--- a/src/mongo/client/replica_set_monitor_interface.h
+++ b/src/mongo/client/replica_set_monitor_interface.h
@@ -85,13 +85,13 @@ public:
const ReadPreferenceSetting& readPref, Milliseconds maxWait = kDefaultFindHostTimeout) = 0;
/**
- * Returns the host the RSM thinks is the current master or uasserts.
+ * Returns the host the RSM thinks is the current primary or uasserts.
*
* This is a thin wrapper around getHostOrRefresh and will also refresh the view if a primary
* does not exist. The main difference is that this will uassert rather than returning an empty
* HostAndPort.
*/
- virtual HostAndPort getMasterOrUassert() = 0;
+ virtual HostAndPort getPrimaryOrUassert() = 0;
/**
* Notifies this Monitor that a host has failed because of the specified error 'status' and
diff --git a/src/mongo/client/scanning_replica_set_monitor.cpp b/src/mongo/client/scanning_replica_set_monitor.cpp
index ed6058bcc76..be7cc455344 100644
--- a/src/mongo/client/scanning_replica_set_monitor.cpp
+++ b/src/mongo/client/scanning_replica_set_monitor.cpp
@@ -350,7 +350,7 @@ Future<std::vector<HostAndPort>> ScanningReplicaSetMonitor::_getHostsOrRefresh(
return std::move(pf.future);
}
-HostAndPort ScanningReplicaSetMonitor::getMasterOrUassert() {
+HostAndPort ScanningReplicaSetMonitor::getPrimaryOrUassert() {
return getHostOrRefresh(kPrimaryOnlyReadPreference).get();
}
@@ -574,7 +574,7 @@ void Refresher::scheduleIsMaster(const HostAndPort& host) {
auto timer = Timer();
auto reply = BSONObj();
bool ignoredOutParam = false;
- conn->isMaster(ignoredOutParam, &reply);
+ conn->isPrimary(ignoredOutParam, &reply);
conn.done(); // return to pool on success.
receivedIsMaster(host, timer.micros(), reply);
diff --git a/src/mongo/client/scanning_replica_set_monitor.h b/src/mongo/client/scanning_replica_set_monitor.h
index 46c839ec8fd..40119cb894e 100644
--- a/src/mongo/client/scanning_replica_set_monitor.h
+++ b/src/mongo/client/scanning_replica_set_monitor.h
@@ -79,7 +79,7 @@ public:
const ReadPreferenceSetting& readPref,
Milliseconds maxWait = kDefaultFindHostTimeout) override;
- HostAndPort getMasterOrUassert() override;
+ HostAndPort getPrimaryOrUassert() override;
/*
* For the ScanningReplicaSetMonitor, all the failedHost methods are equivalent.
diff --git a/src/mongo/client/streamable_replica_set_monitor.cpp b/src/mongo/client/streamable_replica_set_monitor.cpp
index 204c33d4c64..3858293831f 100644
--- a/src/mongo/client/streamable_replica_set_monitor.cpp
+++ b/src/mongo/client/streamable_replica_set_monitor.cpp
@@ -376,7 +376,7 @@ boost::optional<std::vector<HostAndPort>> StreamableReplicaSetMonitor::_getHosts
return _getHosts(_currentTopology(), criteria);
}
-HostAndPort StreamableReplicaSetMonitor::getMasterOrUassert() {
+HostAndPort StreamableReplicaSetMonitor::getPrimaryOrUassert() {
return getHostOrRefresh(kPrimaryOnlyReadPreference).get();
}
diff --git a/src/mongo/client/streamable_replica_set_monitor.h b/src/mongo/client/streamable_replica_set_monitor.h
index bcb5b7cdb76..7c53114e3f3 100644
--- a/src/mongo/client/streamable_replica_set_monitor.h
+++ b/src/mongo/client/streamable_replica_set_monitor.h
@@ -95,7 +95,7 @@ public:
SemiFuture<std::vector<HostAndPort>> getHostsOrRefresh(
const ReadPreferenceSetting& readPref, Milliseconds maxWait = kDefaultFindHostTimeout);
- HostAndPort getMasterOrUassert();
+ HostAndPort getPrimaryOrUassert();
void failedHost(const HostAndPort& host, const Status& status) override;
void failedHostPreHandshake(const HostAndPort& host,
diff --git a/src/mongo/db/dbmessage.h b/src/mongo/db/dbmessage.h
index 8aaf856d595..b8726d98992 100644
--- a/src/mongo/db/dbmessage.h
+++ b/src/mongo/db/dbmessage.h
@@ -299,7 +299,7 @@ enum QueryOptions {
/** allow query of replica slave. normally these return an error except for namespace "local".
*/
- QueryOption_SlaveOk = 1 << 2,
+ QueryOption_SecondaryOk = 1 << 2,
// In previous versions of the server, clients were required to set this option in order to
// enable an optimized oplog scan. As of 4.4, the server will apply the optimization for
@@ -341,11 +341,11 @@ enum QueryOptions {
// DBClientCursor reserves flag 1 << 30 to force the use of OP_QUERY.
- QueryOption_AllSupported = QueryOption_CursorTailable | QueryOption_SlaveOk |
+ QueryOption_AllSupported = QueryOption_CursorTailable | QueryOption_SecondaryOk |
QueryOption_NoCursorTimeout | QueryOption_AwaitData | QueryOption_Exhaust |
QueryOption_PartialResults,
- QueryOption_AllSupportedForSharding = QueryOption_CursorTailable | QueryOption_SlaveOk |
+ QueryOption_AllSupportedForSharding = QueryOption_CursorTailable | QueryOption_SecondaryOk |
QueryOption_NoCursorTimeout | QueryOption_AwaitData | QueryOption_PartialResults,
};
diff --git a/src/mongo/db/exhaust_cursor_currentop_integration_test.cpp b/src/mongo/db/exhaust_cursor_currentop_integration_test.cpp
index 456931fd489..a9f12041aad 100644
--- a/src/mongo/db/exhaust_cursor_currentop_integration_test.cpp
+++ b/src/mongo/db/exhaust_cursor_currentop_integration_test.cpp
@@ -341,7 +341,7 @@ TEST(CurrentOpExhaustCursorTest, ExhaustCursorUpdatesLastKnownCommittedOpTime) {
}
// Connect directly to the primary.
- DBClientBase* conn = &static_cast<DBClientReplicaSet*>(fixtureConn.get())->masterConn();
+ DBClientBase* conn = &static_cast<DBClientReplicaSet*>(fixtureConn.get())->primaryConn();
ASSERT(conn);
conn->dropCollection(testNSS.ns());
@@ -364,7 +364,7 @@ TEST(CurrentOpExhaustCursorTest, ExhaustCursorUpdatesLastKnownCommittedOpTime) {
// Create a new connection to the primary for the exhaust query.
const auto fixtureQueryConn = connect(testBackgroundAppName);
DBClientBase* queryConn =
- &static_cast<DBClientReplicaSet*>(fixtureQueryConn.get())->masterConn();
+ &static_cast<DBClientReplicaSet*>(fixtureQueryConn.get())->primaryConn();
std::unique_ptr<DBClientCursor> queryCursor;
// Enable a failpoint to block getMore during execution to avoid races between getCursorId() and
diff --git a/src/mongo/db/query/query_request.cpp b/src/mongo/db/query/query_request.cpp
index 1c3a5573100..db47e2b0605 100644
--- a/src/mongo/db/query/query_request.cpp
+++ b/src/mongo/db/query/query_request.cpp
@@ -898,7 +898,7 @@ int QueryRequest::getOptions() const {
options |= QueryOption_AwaitData;
}
if (_slaveOk) {
- options |= QueryOption_SlaveOk;
+ options |= QueryOption_SecondaryOk;
}
if (_noCursorTimeout) {
options |= QueryOption_NoCursorTimeout;
@@ -916,7 +916,7 @@ void QueryRequest::initFromInt(int options) {
bool tailable = (options & QueryOption_CursorTailable) != 0;
bool awaitData = (options & QueryOption_AwaitData) != 0;
_tailableMode = uassertStatusOK(tailableModeFromBools(tailable, awaitData));
- _slaveOk = (options & QueryOption_SlaveOk) != 0;
+ _slaveOk = (options & QueryOption_SecondaryOk) != 0;
_noCursorTimeout = (options & QueryOption_NoCursorTimeout) != 0;
_exhaust = (options & QueryOption_Exhaust) != 0;
_allowPartialResults = (options & QueryOption_PartialResults) != 0;
diff --git a/src/mongo/db/repl/collection_cloner.cpp b/src/mongo/db/repl/collection_cloner.cpp
index 77a37ee1a38..365db4c4d19 100644
--- a/src/mongo/db/repl/collection_cloner.cpp
+++ b/src/mongo/db/repl/collection_cloner.cpp
@@ -145,7 +145,7 @@ BaseCloner::AfterStageBehavior CollectionCloner::CollectionClonerStage::run() {
BaseCloner::AfterStageBehavior CollectionCloner::countStage() {
auto count = getClient()->count(_sourceDbAndUuid,
{} /* Query */,
- QueryOption_SlaveOk,
+ QueryOption_SecondaryOk,
0 /* limit */,
0 /* skip */,
ReadConcernArgs::kImplicitDefault);
@@ -171,7 +171,7 @@ BaseCloner::AfterStageBehavior CollectionCloner::countStage() {
BaseCloner::AfterStageBehavior CollectionCloner::listIndexesStage() {
const bool includeBuildUUIDs = true;
auto indexSpecs =
- getClient()->getIndexSpecs(_sourceDbAndUuid, includeBuildUUIDs, QueryOption_SlaveOk);
+ getClient()->getIndexSpecs(_sourceDbAndUuid, includeBuildUUIDs, QueryOption_SecondaryOk);
if (indexSpecs.empty()) {
LOGV2_WARNING(21143,
"No indexes found for collection {namespace} while cloning from {source}",
@@ -308,7 +308,7 @@ void CollectionCloner::runQuery() {
_sourceDbAndUuid,
query,
nullptr /* fieldsToReturn */,
- QueryOption_NoCursorTimeout | QueryOption_SlaveOk |
+ QueryOption_NoCursorTimeout | QueryOption_SecondaryOk |
(collectionClonerUsesExhaust ? QueryOption_Exhaust : 0),
_collectionClonerBatchSize,
ReadConcernArgs::kImplicitDefault);
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index bdc2998b901..ddbf101aea1 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -1776,7 +1776,7 @@ void initTimestampFromOplog(OperationContext* opCtx, const NamespaceString& oplo
DBDirectClient c(opCtx);
static const BSONObj reverseNaturalObj = BSON("$natural" << -1);
BSONObj lastOp =
- c.findOne(oplogNss.ns(), Query().sort(reverseNaturalObj), nullptr, QueryOption_SlaveOk);
+ c.findOne(oplogNss.ns(), Query().sort(reverseNaturalObj), nullptr, QueryOption_SecondaryOk);
if (!lastOp.isEmpty()) {
LOGV2_DEBUG(21256, 1, "replSet setting last Timestamp");
diff --git a/src/mongo/db/repl/rollback_source_impl.cpp b/src/mongo/db/repl/rollback_source_impl.cpp
index 81edccee6ed..7a9cb01ec62 100644
--- a/src/mongo/db/repl/rollback_source_impl.cpp
+++ b/src/mongo/db/repl/rollback_source_impl.cpp
@@ -67,14 +67,20 @@ int RollbackSourceImpl::getRollbackId() const {
BSONObj RollbackSourceImpl::getLastOperation() const {
const Query query = Query().sort(BSON("$natural" << -1));
- return _getConnection()->findOne(
- _collectionName, query, nullptr, QueryOption_SlaveOk, ReadConcernArgs::kImplicitDefault);
+ return _getConnection()->findOne(_collectionName,
+ query,
+ nullptr,
+ QueryOption_SecondaryOk,
+ ReadConcernArgs::kImplicitDefault);
}
BSONObj RollbackSourceImpl::findOne(const NamespaceString& nss, const BSONObj& filter) const {
return _getConnection()
- ->findOne(
- nss.toString(), filter, nullptr, QueryOption_SlaveOk, ReadConcernArgs::kImplicitDefault)
+ ->findOne(nss.toString(),
+ filter,
+ nullptr,
+ QueryOption_SecondaryOk,
+ ReadConcernArgs::kImplicitDefault)
.getOwned();
}
diff --git a/src/mongo/db/repl/tenant_all_database_cloner.cpp b/src/mongo/db/repl/tenant_all_database_cloner.cpp
index a1f1728ba2f..6f5ff569705 100644
--- a/src/mongo/db/repl/tenant_all_database_cloner.cpp
+++ b/src/mongo/db/repl/tenant_all_database_cloner.cpp
@@ -85,7 +85,7 @@ BaseCloner::AfterStageBehavior TenantAllDatabaseCloner::listDatabasesStage() {
BSONObj readResult;
BSONObj cmd = ClonerUtils::buildMajorityWaitRequest(_operationTime);
- getClient()->runCommand("admin", cmd, readResult, QueryOption_SlaveOk);
+ getClient()->runCommand("admin", cmd, readResult, QueryOption_SecondaryOk);
uassertStatusOKWithContext(
getStatusFromCommandResult(readResult),
"TenantAllDatabaseCloner failed to get listDatabases result majority-committed");
diff --git a/src/mongo/db/repl/tenant_collection_cloner.cpp b/src/mongo/db/repl/tenant_collection_cloner.cpp
index e1e023960d2..1c1bbe88edc 100644
--- a/src/mongo/db/repl/tenant_collection_cloner.cpp
+++ b/src/mongo/db/repl/tenant_collection_cloner.cpp
@@ -135,7 +135,7 @@ BaseCloner::AfterStageBehavior TenantCollectionCloner::TenantCollectionClonerSta
BaseCloner::AfterStageBehavior TenantCollectionCloner::countStage() {
auto count = getClient()->count(_sourceDbAndUuid,
{} /* Query */,
- QueryOption_SlaveOk,
+ QueryOption_SecondaryOk,
0 /* limit */,
0 /* skip */,
ReadConcernArgs::kImplicitDefault);
@@ -165,7 +165,7 @@ BaseCloner::AfterStageBehavior TenantCollectionCloner::listIndexesStage() {
_operationTime = Timestamp();
auto indexSpecs = getClient()->getIndexSpecs(
- _sourceDbAndUuid, false /* includeBuildUUIDs */, QueryOption_SlaveOk);
+ _sourceDbAndUuid, false /* includeBuildUUIDs */, QueryOption_SecondaryOk);
// Do a majority read on the sync source to make sure the indexes listed exist on a majority of
// nodes in the set. We do not check the rollbackId - rollback would lead to the sync source
@@ -193,7 +193,7 @@ BaseCloner::AfterStageBehavior TenantCollectionCloner::listIndexesStage() {
BSONObj readResult;
BSONObj cmd = ClonerUtils::buildMajorityWaitRequest(_operationTime);
- getClient()->runCommand("admin", cmd, readResult, QueryOption_SlaveOk);
+ getClient()->runCommand("admin", cmd, readResult, QueryOption_SecondaryOk);
uassertStatusOKWithContext(
getStatusFromCommandResult(readResult),
"TenantCollectionCloner failed to get listIndexes result majority-committed");
@@ -282,7 +282,7 @@ void TenantCollectionCloner::runQuery() {
_sourceDbAndUuid,
query,
nullptr /* fieldsToReturn */,
- QueryOption_NoCursorTimeout | QueryOption_SlaveOk |
+ QueryOption_NoCursorTimeout | QueryOption_SecondaryOk |
(collectionClonerUsesExhaust ? QueryOption_Exhaust : 0),
_collectionClonerBatchSize);
_dbWorkTaskRunner.join();
diff --git a/src/mongo/db/repl/tenant_database_cloner.cpp b/src/mongo/db/repl/tenant_database_cloner.cpp
index 4294020a281..7b6cb2d7926 100644
--- a/src/mongo/db/repl/tenant_database_cloner.cpp
+++ b/src/mongo/db/repl/tenant_database_cloner.cpp
@@ -105,7 +105,7 @@ BaseCloner::AfterStageBehavior TenantDatabaseCloner::listCollectionsStage() {
BSONObj readResult;
BSONObj cmd = ClonerUtils::buildMajorityWaitRequest(_operationTime);
- getClient()->runCommand("admin", cmd, readResult, QueryOption_SlaveOk);
+ getClient()->runCommand("admin", cmd, readResult, QueryOption_SecondaryOk);
uassertStatusOKWithContext(
getStatusFromCommandResult(readResult),
"TenantDatabaseCloner failed to get listCollections result majority-committed");
diff --git a/src/mongo/db/repl/tenant_migration_recipient_service.cpp b/src/mongo/db/repl/tenant_migration_recipient_service.cpp
index 13ab60cebba..a10ab36b14c 100644
--- a/src/mongo/db/repl/tenant_migration_recipient_service.cpp
+++ b/src/mongo/db/repl/tenant_migration_recipient_service.cpp
@@ -387,7 +387,7 @@ void TenantMigrationRecipientService::Instance::_getStartOpTimesFromDonor(WithLo
_client->findOne(NamespaceString::kRsOplogNamespace.ns(),
Query().sort("$natural", -1),
&oplogOpTimeFields,
- QueryOption_SlaveOk,
+ QueryOption_SecondaryOk,
ReadConcernArgs(ReadConcernLevel::kMajorityReadConcern).toBSONInner());
uassert(4880601, "Found no entries in the remote oplog", !lastOplogEntry1Bson.isEmpty());
LOGV2_DEBUG(4880600,
@@ -409,7 +409,7 @@ void TenantMigrationRecipientService::Instance::_getStartOpTimesFromDonor(WithLo
QUERY("state" << BSON("$in" << BSON_ARRAY(preparedState << inProgressState)))
.sort(SessionTxnRecord::kStartOpTimeFieldName.toString(), 1),
&transactionTableOpTimeFields,
- QueryOption_SlaveOk,
+ QueryOption_SecondaryOk,
ReadConcernArgs(ReadConcernLevel::kMajorityReadConcern).toBSONInner());
LOGV2_DEBUG(4880602,
2,
@@ -428,7 +428,7 @@ void TenantMigrationRecipientService::Instance::_getStartOpTimesFromDonor(WithLo
_client->findOne(NamespaceString::kRsOplogNamespace.ns(),
Query().sort("$natural", -1),
&oplogOpTimeFields,
- QueryOption_SlaveOk,
+ QueryOption_SecondaryOk,
ReadConcernArgs(ReadConcernLevel::kMajorityReadConcern).toBSONInner());
uassert(4880603, "Found no entries in the remote oplog", !lastOplogEntry2Bson.isEmpty());
LOGV2_DEBUG(4880604,
diff --git a/src/mongo/rpc/legacy_request_builder.cpp b/src/mongo/rpc/legacy_request_builder.cpp
index 1a52bec654d..66ed5eeb069 100644
--- a/src/mongo/rpc/legacy_request_builder.cpp
+++ b/src/mongo/rpc/legacy_request_builder.cpp
@@ -64,7 +64,7 @@ BSONObj downconvertRequestBody(const OpMsgRequest& request, int* queryOptions) {
if (auto readPref = request.body["$readPreference"]) {
auto parsed = ReadPreferenceSetting::fromInnerBSON(readPref);
if (parsed.isOK() && parsed.getValue().canRunOnSecondary()) {
- *queryOptions |= QueryOption_SlaveOk;
+ *queryOptions |= QueryOption_SecondaryOk;
}
BSONObjBuilder outer;
diff --git a/src/mongo/rpc/legacy_request_test.cpp b/src/mongo/rpc/legacy_request_test.cpp
index 896f7150306..ac8fa3a4c2f 100644
--- a/src/mongo/rpc/legacy_request_test.cpp
+++ b/src/mongo/rpc/legacy_request_test.cpp
@@ -74,7 +74,7 @@ TEST(LegacyRequestBuilder, DownconvertSecondaryReadPreference) {
auto parsed = QueryMessage(msg);
ASSERT_EQ(parsed.ns, "admin.$cmd"_sd);
- ASSERT_EQ(parsed.queryOptions, QueryOption_SlaveOk);
+ ASSERT_EQ(parsed.queryOptions, QueryOption_SecondaryOk);
ASSERT_BSONOBJ_EQ(parsed.query,
fromjson("{$query: {ping: 1}, $readPreference : {mode: 'secondary'}}"));
}
diff --git a/src/mongo/rpc/metadata.cpp b/src/mongo/rpc/metadata.cpp
index a6e9bde0ebf..42b85765f42 100644
--- a/src/mongo/rpc/metadata.cpp
+++ b/src/mongo/rpc/metadata.cpp
@@ -164,7 +164,7 @@ OpMsgRequest upconvertRequest(StringData db, BSONObj cmdObj, int queryFlags) {
if (!readPrefContainer.isEmpty()) {
cmdObj = BSONObjBuilder(std::move(cmdObj)).appendElements(readPrefContainer).obj();
- } else if (!cmdObj.hasField("$readPreference") && (queryFlags & QueryOption_SlaveOk)) {
+ } else if (!cmdObj.hasField("$readPreference") && (queryFlags & QueryOption_SecondaryOk)) {
BSONObjBuilder bodyBuilder(std::move(cmdObj));
ReadPreferenceSetting(ReadPreference::SecondaryPreferred).toContainingBSON(&bodyBuilder);
cmdObj = bodyBuilder.obj();
diff --git a/src/mongo/rpc/metadata_test.cpp b/src/mongo/rpc/metadata_test.cpp
index c0bac93aedd..d35a37d1b8d 100644
--- a/src/mongo/rpc/metadata_test.cpp
+++ b/src/mongo/rpc/metadata_test.cpp
@@ -71,7 +71,7 @@ TEST(Metadata, UpconvertValidMetadata) {
"$readPreference"
<< BSON("mode"
<< "secondary")),
- mongo::QueryOption_SlaveOk,
+ mongo::QueryOption_SecondaryOk,
BSON("ping" << 1 << "$readPreference"
<< BSON("mode"
<< "secondary")));
diff --git a/src/mongo/rpc/op_msg_integration_test.cpp b/src/mongo/rpc/op_msg_integration_test.cpp
index c273f3f16c9..78bbe3d17db 100644
--- a/src/mongo/rpc/op_msg_integration_test.cpp
+++ b/src/mongo/rpc/op_msg_integration_test.cpp
@@ -204,9 +204,9 @@ TEST(OpMsg, CloseConnectionOnFireAndForgetNotWritablePrimaryError) {
for (auto host : connStr.getServers()) {
DBClientConnection conn;
uassertStatusOK(conn.connect(host, "integration_test"));
- bool isMaster;
- ASSERT(conn.isMaster(isMaster));
- if (isMaster)
+ bool isPrimary;
+ ASSERT(conn.isPrimary(isPrimary));
+ if (isPrimary)
continue;
foundSecondary = true;
@@ -564,7 +564,7 @@ TEST(OpMsg, ServerHandlesExhaustIsMasterCorrectly) {
if (fixtureConn->isReplicaSetMember()) {
// Connect directly to the primary.
- conn = &static_cast<DBClientReplicaSet*>(fixtureConn.get())->masterConn();
+ conn = &static_cast<DBClientReplicaSet*>(fixtureConn.get())->primaryConn();
ASSERT(conn);
}
@@ -627,7 +627,7 @@ TEST(OpMsg, ServerHandlesExhaustIsMasterWithTopologyChange) {
if (fixtureConn->isReplicaSetMember()) {
// Connect directly to the primary.
- conn = &static_cast<DBClientReplicaSet*>(fixtureConn.get())->masterConn();
+ conn = &static_cast<DBClientReplicaSet*>(fixtureConn.get())->primaryConn();
ASSERT(conn);
}
@@ -693,7 +693,7 @@ TEST(OpMsg, ServerRejectsExhaustIsMasterWithoutMaxAwaitTimeMS) {
if (fixtureConn->isReplicaSetMember()) {
// Connect directly to the primary.
- conn = &static_cast<DBClientReplicaSet*>(fixtureConn.get())->masterConn();
+ conn = &static_cast<DBClientReplicaSet*>(fixtureConn.get())->primaryConn();
ASSERT(conn);
}
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp
index 364b385ec8d..6cd8f17287d 100644
--- a/src/mongo/s/commands/strategy.cpp
+++ b/src/mongo/s/commands/strategy.cpp
@@ -951,7 +951,7 @@ DbResponse Strategy::queryOp(OperationContext* opCtx, const NamespaceString& nss
}
// Determine the default read preference mode based on the value of the slaveOk flag.
- const auto defaultReadPref = q.queryOptions & QueryOption_SlaveOk
+ const auto defaultReadPref = q.queryOptions & QueryOption_SecondaryOk
? ReadPreference::SecondaryPreferred
: ReadPreference::PrimaryOnly;
ReadPreferenceSetting::get(opCtx) =
diff --git a/src/mongo/scripting/engine.cpp b/src/mongo/scripting/engine.cpp
index 90f29d579cf..5b8e04d4c75 100644
--- a/src/mongo/scripting/engine.cpp
+++ b/src/mongo/scripting/engine.cpp
@@ -233,7 +233,7 @@ void Scope::loadStored(OperationContext* opCtx, bool ignoreNotConnected) {
auto directDBClient = DBDirectClientFactory::get(opCtx).create(opCtx);
unique_ptr<DBClientCursor> c =
- directDBClient->query(coll, Query(), 0, 0, nullptr, QueryOption_SlaveOk, 0);
+ directDBClient->query(coll, Query(), 0, 0, nullptr, QueryOption_SecondaryOk, 0);
massert(16669, "unable to get db client cursor from query", c.get());
set<string> thisTime;