diff options
Diffstat (limited to 'src/mongo/shell/bench.cpp')
-rw-r--r-- | src/mongo/shell/bench.cpp | 39 |
1 files changed, 4 insertions, 35 deletions
diff --git a/src/mongo/shell/bench.cpp b/src/mongo/shell/bench.cpp index 1de6b59fff3..1f5fd3e4775 100644 --- a/src/mongo/shell/bench.cpp +++ b/src/mongo/shell/bench.cpp @@ -34,7 +34,6 @@ #include "mongo/shell/bench.h" #include <pcrecpp.h> -#include <string> #include "mongo/client/dbclient_cursor.h" #include "mongo/db/namespace_string.h" @@ -232,20 +231,16 @@ int runQueryWithReadCommands(DBClientBase* conn, boost::optional<TxnNumber> txnNumber, std::unique_ptr<QueryRequest> qr, Milliseconds delayBeforeGetMore, - BSONObj readPrefObj, BSONObj* objOut) { const auto dbName = qr->nss().db().toString(); BSONObj findCommandResult; - BSONObjBuilder findCommandBuilder; - qr->asFindCommand(&findCommandBuilder); - findCommandBuilder.append("$readPreference", readPrefObj); uassert(ErrorCodes::CommandFailed, str::stream() << "find command failed; reply was: " << findCommandResult, runCommandWithSession( conn, dbName, - findCommandBuilder.obj(), + qr->asFindCommand(), // read command with txnNumber implies performing reads in a // multi-statement transaction txnNumber ? kStartTransactionOption | kMultiStatementTransactionOption : kNoOptions, @@ -314,7 +309,7 @@ Timestamp getLatestClusterTime(DBClientBase* conn) { BSONObj oplogResult; int count = runQueryWithReadCommands( - conn, boost::none, boost::none, std::move(qr), Milliseconds(0), BSONObj(), &oplogResult); + conn, boost::none, boost::none, std::move(qr), Milliseconds(0), &oplogResult); uassert(ErrorCodes::OperationFailed, str::stream() << "Find cmd on the oplog collection failed; reply was: " << oplogResult, count == 1); @@ -642,26 +637,6 @@ BenchRunOp opFromBson(const BSONObj& op) { << opType, (opType == "find") || (opType == "query")); myOp.maxRandomMillisecondDelayBeforeGetMore = arg.numberInt(); - } else if (name == "readPrefMode") { - uassert( - ErrorCodes::InvalidOptions, - str::stream() << "Field 'readPrefMode' is only valid for find op types. Type is " - << opType, - (opType == "find") || (opType == "query") || (opType == "findOne")); - uassert(ErrorCodes::BadValue, - str::stream() << "Field 'readPrefMode' should be a string, instead it's type: " - << typeName(arg.type()), - arg.type() == BSONType::String); - - ReadPreference mode; - try { - mode = ReadPreference_parse(IDLParserErrorContext("mode"), arg.str()); - } catch (DBException& e) { - e.addContext("benchRun(): Could not parse readPrefMode argument"); - throw; - } - - myOp.readPrefObj = ReadPreferenceSetting(mode).toInnerBSON(); } else { uassert(34394, str::stream() << "Benchrun op has unsupported field: " << name, false); } @@ -1045,13 +1020,8 @@ void BenchRunOp::executeOnce(DBClientBase* conn, txnNumberForOp = state->txnNumber; state->inProgressMultiStatementTxn = true; } - runQueryWithReadCommands(conn, - lsid, - txnNumberForOp, - std::move(qr), - Milliseconds(0), - readPrefObj, - &result); + runQueryWithReadCommands( + conn, lsid, txnNumberForOp, std::move(qr), Milliseconds(0), &result); } else { if (!this->sort.isEmpty()) { fixedQuery = makeQueryLegacyCompatible(std::move(fixedQuery), this->sort); @@ -1167,7 +1137,6 @@ void BenchRunOp::executeOnce(DBClientBase* conn, txnNumberForOp, std::move(qr), Milliseconds(delayBeforeGetMore), - readPrefObj, nullptr); } else { if (!this->sort.isEmpty()) { |