summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNatalie Tsvetkova <natalie.tsvetkova@mongodb.com>2018-11-12 13:34:26 -0500
committerNatalie Tsvetkova <natalie.tsvetkova@mongodb.com>2018-11-13 16:21:20 -0500
commit7b0362b91d01a40bb19398d11381516a0783aa67 (patch)
tree1d7accff8d3154bab16aae7901bddbc5436db35a /src
parent993eb907d60eecc680dbee5eb8ced72a8533e9b7 (diff)
downloadmongo-7b0362b91d01a40bb19398d11381516a0783aa67.tar.gz
SERVER-38054: failCommand fail point causes errors when run concurrently with other tests
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/commands.cpp13
-rw-r--r--src/mongo/db/commands.h4
-rw-r--r--src/mongo/db/service_entry_point_common.cpp2
-rw-r--r--src/mongo/s/commands/strategy.cpp4
4 files changed, 17 insertions, 6 deletions
diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp
index 31522e64fda..cea4b6c06c1 100644
--- a/src/mongo/db/commands.cpp
+++ b/src/mongo/db/commands.cpp
@@ -465,10 +465,19 @@ constexpr StringData CommandHelpers::kHelpFieldName;
MONGO_FAIL_POINT_DEFINE(failCommand);
-bool CommandHelpers::shouldActivateFailCommandFailPoint(const BSONObj& data, StringData cmdName) {
+bool CommandHelpers::shouldActivateFailCommandFailPoint(const BSONObj& data,
+ StringData cmdName,
+ Client* client) {
if (cmdName == "configureFailPoint"_sd) // Banned even if in failCommands.
return false;
+ if (data.hasField("threadName") &&
+ (client->desc() !=
+ data.getStringField(
+ "threadName"))) { // only activate failpoint on thread from certain client
+ return false;
+ }
+
for (auto&& failCommand : data.getObjectField("failCommands")) {
if (failCommand.type() == String && failCommand.valueStringData() == cmdName) {
return true;
@@ -480,7 +489,7 @@ bool CommandHelpers::shouldActivateFailCommandFailPoint(const BSONObj& data, Str
void CommandHelpers::evaluateFailCommandFailPoint(OperationContext* opCtx, StringData commandName) {
MONGO_FAIL_POINT_BLOCK_IF(failCommand, data, [&](const BSONObj& data) {
- return shouldActivateFailCommandFailPoint(data, commandName) &&
+ return shouldActivateFailCommandFailPoint(data, commandName, opCtx->getClient()) &&
(data.hasField("closeConnection") || data.hasField("errorCode"));
}) {
bool closeConnection;
diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h
index d2445729ee8..71e75362643 100644
--- a/src/mongo/db/commands.h
+++ b/src/mongo/db/commands.h
@@ -252,7 +252,9 @@ struct CommandHelpers {
/**
* Checks if the command passed in is in the list of failCommands defined in the fail point.
*/
- static bool shouldActivateFailCommandFailPoint(const BSONObj& data, StringData cmdName);
+ static bool shouldActivateFailCommandFailPoint(const BSONObj& data,
+ StringData cmdName,
+ Client* client);
/**
* Possibly uasserts according to the "failCommand" fail point.
diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp
index a0d7f96ff02..ea35c127d58 100644
--- a/src/mongo/db/service_entry_point_common.cpp
+++ b/src/mongo/db/service_entry_point_common.cpp
@@ -448,7 +448,7 @@ bool runCommandImpl(OperationContext* opCtx,
auto waitForWriteConcern = [&](auto&& bb) {
MONGO_FAIL_POINT_BLOCK_IF(failCommand, data, [&](const BSONObj& data) {
return CommandHelpers::shouldActivateFailCommandFailPoint(
- data, request.getCommandName()) &&
+ data, request.getCommandName(), opCtx->getClient()) &&
data.hasField("writeConcernError");
}) {
bb.append(data.getData()["writeConcernError"]);
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp
index 116ad48fe31..1281702a53b 100644
--- a/src/mongo/s/commands/strategy.cpp
+++ b/src/mongo/s/commands/strategy.cpp
@@ -302,8 +302,8 @@ void execCommandClient(OperationContext* opCtx,
auto body = result->getBodyBuilder();
MONGO_FAIL_POINT_BLOCK_IF(failCommand, data, [&](const BSONObj& data) {
- return CommandHelpers::shouldActivateFailCommandFailPoint(data,
- request.getCommandName()) &&
+ return CommandHelpers::shouldActivateFailCommandFailPoint(
+ data, request.getCommandName(), opCtx->getClient()) &&
data.hasField("writeConcernError");
}) {
body.append(data.getData()["writeConcernError"]);