diff options
Diffstat (limited to 'src/mongo/client/dbclient_rs.cpp')
-rw-r--r-- | src/mongo/client/dbclient_rs.cpp | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/src/mongo/client/dbclient_rs.cpp b/src/mongo/client/dbclient_rs.cpp index b7e2044f93c..978cef3182e 100644 --- a/src/mongo/client/dbclient_rs.cpp +++ b/src/mongo/client/dbclient_rs.cpp @@ -49,12 +49,12 @@ namespace mongo { -using std::shared_ptr; -using std::unique_ptr; using std::endl; using std::map; using std::set; +using std::shared_ptr; using std::string; +using std::unique_ptr; using std::vector; namespace { @@ -314,9 +314,9 @@ DBClientConnection* DBClientReplicaSet::checkMaster() { } if (newConn == nullptr || !errmsg.empty()) { - const std::string message = str::stream() << "can't connect to new replica set master [" - << _masterHost.toString() << "]" - << (errmsg.empty() ? "" : ", err: ") << errmsg; + const std::string message = str::stream() + << "can't connect to new replica set master [" << _masterHost.toString() << "]" + << (errmsg.empty() ? "" : ", err: ") << errmsg; monitor->failedHost(_masterHost, {ErrorCodes::Error(40659), message}); uasserted(ErrorCodes::FailedToSatisfyReadPreference, message); } @@ -537,9 +537,9 @@ unique_ptr<DBClientCursor> DBClientReplicaSet::query(const NamespaceStringOrUUID << _getMonitor()->getName() << ", read pref is " << readPref->toString() << " (primary : " << (_master.get() != nullptr ? _master->getServerAddress() : "[not cached]") - << ", lastTagged : " << (_lastSlaveOkConn.get() != nullptr - ? _lastSlaveOkConn->getServerAddress() - : "[not cached]") + << ", lastTagged : " + << (_lastSlaveOkConn.get() != nullptr ? _lastSlaveOkConn->getServerAddress() + : "[not cached]") << ")" << endl; string lastNodeErrMsg; @@ -589,9 +589,9 @@ BSONObj DBClientReplicaSet::findOne(const string& ns, << _getMonitor()->getName() << ", read pref is " << readPref->toString() << " (primary : " << (_master.get() != nullptr ? _master->getServerAddress() : "[not cached]") - << ", lastTagged : " << (_lastSlaveOkConn.get() != nullptr - ? _lastSlaveOkConn->getServerAddress() - : "[not cached]") + << ", lastTagged : " + << (_lastSlaveOkConn.get() != nullptr ? _lastSlaveOkConn->getServerAddress() + : "[not cached]") << ")" << endl; string lastNodeErrMsg; @@ -719,7 +719,7 @@ DBClientConnection* DBClientReplicaSet::selectNodeUsingTags( return _master.get(); } - auto dtor = [host = _lastSlaveOkHost.toString()](DBClientConnection * ptr) { + auto dtor = [host = _lastSlaveOkHost.toString()](DBClientConnection* ptr) { globalConnPool.release(host, ptr); }; @@ -768,9 +768,9 @@ void DBClientReplicaSet::say(Message& toSend, bool isRetry, string* actualServer << _getMonitor()->getName() << ", read pref is " << readPref->toString() << " (primary : " << (_master.get() != nullptr ? _master->getServerAddress() : "[not cached]") - << ", lastTagged : " << (_lastSlaveOkConn.get() != nullptr - ? _lastSlaveOkConn->getServerAddress() - : "[not cached]") + << ", lastTagged : " + << (_lastSlaveOkConn.get() != nullptr ? _lastSlaveOkConn->getServerAddress() + : "[not cached]") << ")" << endl; string lastNodeErrMsg; @@ -882,8 +882,9 @@ void DBClientReplicaSet::checkResponse(const std::vector<BSONObj>& batch, // query could potentially go to a secondary, so see if this is an error (or empty) and // retry if we're not past our retry limit. - if (networkError || (hasErrField(dataObj) && !dataObj["code"].eoo() && - dataObj["code"].Int() == ErrorCodes::NotMasterOrSecondary)) { + if (networkError || + (hasErrField(dataObj) && !dataObj["code"].eoo() && + dataObj["code"].Int() == ErrorCodes::NotMasterOrSecondary)) { if (_lazyState._lastClient == _lastSlaveOkConn.get()) { isntSecondary(); } else if (_lazyState._lastClient == _master.get()) { @@ -905,8 +906,9 @@ 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 (networkError || (hasErrField(dataObj) && !dataObj["code"].eoo() && - dataObj["code"].Int() == ErrorCodes::NotMasterNoSlaveOk)) { + if (networkError || + (hasErrField(dataObj) && !dataObj["code"].eoo() && + dataObj["code"].Int() == ErrorCodes::NotMasterNoSlaveOk)) { if (_lazyState._lastClient == _master.get()) { isntMaster(); } @@ -957,8 +959,7 @@ std::pair<rpc::UniqueReply, DBClientBase*> DBClientReplicaSet::runCommandWithTar uasserted(ErrorCodes::HostNotFound, str::stream() << "Could not satisfy $readPreference of '" << readPref.toString() - << "' while attempting to run command " - << request.getCommandName()); + << "' while attempting to run command " << request.getCommandName()); } std::pair<rpc::UniqueReply, std::shared_ptr<DBClientBase>> DBClientReplicaSet::runCommandWithTarget( @@ -999,9 +1000,9 @@ bool DBClientReplicaSet::call(Message& toSend, << _getMonitor()->getName() << ", read pref is " << readPref->toString() << " (primary : " << (_master.get() != nullptr ? _master->getServerAddress() : "[not cached]") - << ", lastTagged : " << (_lastSlaveOkConn.get() != nullptr - ? _lastSlaveOkConn->getServerAddress() - : "[not cached]") + << ", lastTagged : " + << (_lastSlaveOkConn.get() != nullptr ? _lastSlaveOkConn->getServerAddress() + : "[not cached]") << ")" << endl; for (size_t retry = 0; retry < MAX_RETRY; retry++) { |