summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorSiyuan Zhou <siyuan.zhou@mongodb.com>2019-05-09 00:49:42 -0400
committerSiyuan Zhou <siyuan.zhou@mongodb.com>2019-05-09 00:49:42 -0400
commit1b8a9f5dc5c3314042b55e7415a2a25045b32a94 (patch)
tree90170ef90a95ec36a601f03db09f6184a556dcd3 /src/mongo
parentfb97757aed27a719ca48e0794f29006dec1a7dac (diff)
downloadmongo-1b8a9f5dc5c3314042b55e7415a2a25045b32a94.tar.gz
Revert "SERVER-40567 benchRun support for pipeline updates"r4.1.11
This reverts commit c24b5c1df7d946dd1c931f5c93c7098c9cf8545d.
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/shell/bench.cpp51
-rw-r--r--src/mongo/shell/bench.h3
-rw-r--r--src/mongo/shell/dbshell.cpp10
3 files changed, 14 insertions, 50 deletions
diff --git a/src/mongo/shell/bench.cpp b/src/mongo/shell/bench.cpp
index 78769755580..2b09ed443a5 100644
--- a/src/mongo/shell/bench.cpp
+++ b/src/mongo/shell/bench.cpp
@@ -558,7 +558,7 @@ BenchRunOp opFromBson(const BSONObj& op) {
str::stream() << "Field 'update' is only valid for update op type. Op type is "
<< opType,
(opType == "update"));
- myOp.update = write_ops::UpdateModification::parseFromBSON(arg);
+ myOp.update = arg.Obj();
} else if (name == "upsert") {
uassert(34392,
str::stream() << "Field 'upsert' is only valid for update op type. Op type is "
@@ -931,7 +931,7 @@ void BenchRunWorker::generateLoadOnConnection(DBClientBase* conn) {
return;
}
if (!_config->handleErrors && !op.handleError)
- throw;
+ return;
sleepFor(_config->delayMillisOnFailedOperation);
@@ -1151,36 +1151,16 @@ void BenchRunOp::executeOnce(DBClientBase* conn,
{
BenchRunEventTrace _bret(&state->stats->updateCounter);
BSONObj query = fixQuery(this->query, *state->bsonTemplateEvaluator);
+ BSONObj update = fixQuery(this->update, *state->bsonTemplateEvaluator);
if (this->useWriteCmd) {
BSONObjBuilder builder;
builder.append("update", nsToCollectionSubstring(this->ns));
- BSONArrayBuilder updateArray(builder.subarrayStart("updates"));
- {
- BSONObjBuilder singleUpdate;
- singleUpdate.append("q", query);
- switch (this->update.type()) {
- case write_ops::UpdateModification::Type::kClassic: {
- singleUpdate.append("u",
- fixQuery(this->update.getUpdateClassic(),
- *state->bsonTemplateEvaluator));
- break;
- }
- case write_ops::UpdateModification::Type::kPipeline: {
- BSONArrayBuilder pipelineBuilder(singleUpdate.subarrayStart("u"));
- for (auto&& stage : this->update.getUpdatePipeline()) {
- pipelineBuilder.append(
- fixQuery(stage, *state->bsonTemplateEvaluator));
- }
- pipelineBuilder.doneFast();
- break;
- }
- }
- singleUpdate.append("multi", this->multi);
- singleUpdate.append("upsert", this->upsert);
- updateArray.append(singleUpdate.done());
- }
- updateArray.doneFast();
+ BSONArrayBuilder docBuilder(builder.subarrayStart("updates"));
+ docBuilder.append(BSON("q" << query << "u" << update << "multi" << this->multi
+ << "upsert"
+ << this->upsert));
+ docBuilder.done();
builder.append("writeConcern", this->writeConcern);
boost::optional<TxnNumber> txnNumberForOp;
@@ -1196,16 +1176,11 @@ void BenchRunOp::executeOnce(DBClientBase* conn,
txnNumberForOp,
&result);
} else {
- uassert(
- 30015,
- "cannot use legacy write protocol for anything but classic style updates",
- this->update.type() == write_ops::UpdateModification::Type::kClassic);
- auto toSend = makeUpdateMessage(
- this->ns,
- query,
- fixQuery(this->update.getUpdateClassic(), *state->bsonTemplateEvaluator),
- (this->upsert ? UpdateOption_Upsert : 0) |
- (this->multi ? UpdateOption_Multi : 0));
+ auto toSend = makeUpdateMessage(this->ns,
+ query,
+ update,
+ (this->upsert ? UpdateOption_Upsert : 0) |
+ (this->multi ? UpdateOption_Multi : 0));
conn->say(toSend);
if (this->safe)
result = conn->getLastErrorDetailed();
diff --git a/src/mongo/shell/bench.h b/src/mongo/shell/bench.h
index 527beecae49..7683ad4b089 100644
--- a/src/mongo/shell/bench.h
+++ b/src/mongo/shell/bench.h
@@ -36,7 +36,6 @@
#include "mongo/client/dbclient_base.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/logical_session_id.h"
-#include "mongo/db/ops/write_ops_parsers.h"
#include "mongo/platform/atomic_word.h"
#include "mongo/stdx/condition_variable.h"
#include "mongo/stdx/mutex.h"
@@ -117,7 +116,7 @@ struct BenchRunOp {
bool showResult = false;
std::string target;
bool throwGLE = false;
- write_ops::UpdateModification update;
+ BSONObj update;
bool upsert = false;
bool useCheck = false;
bool useReadCmd = false;
diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp
index f7ff703b665..633a99d8fc5 100644
--- a/src/mongo/shell/dbshell.cpp
+++ b/src/mongo/shell/dbshell.cpp
@@ -46,7 +46,6 @@
#include "mongo/client/mongo_uri.h"
#include "mongo/db/auth/sasl_command_constants.h"
#include "mongo/db/client.h"
-#include "mongo/db/commands/test_commands_enabled.h"
#include "mongo/db/log_process_details.h"
#include "mongo/db/server_options.h"
#include "mongo/logger/console_appender.h"
@@ -106,15 +105,6 @@ MONGO_INITIALIZER_WITH_PREREQUISITES(SetFeatureCompatibilityVersion42, ("EndStar
ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42);
return Status::OK();
}
-
-// Initialize the testCommandsEnabled server parameter to true since the mongo shell does not have
-// any test-only commands that could cause harm to the server, and it may be necessary to enable
-// this to test certain features, for example through benchRun (see SERVER-40419).
-MONGO_INITIALIZER_WITH_PREREQUISITES(EnableShellTestCommands, ("EndStartupOptionSetup"))
-(InitializerContext* context) {
- setTestCommandsEnabled(true);
- return Status::OK();
-}
const auto kAuthParam = "authSource"s;
/**