diff options
author | jannaerin <golden.janna@gmail.com> | 2019-02-06 13:46:48 -0500 |
---|---|---|
committer | jannaerin <golden.janna@gmail.com> | 2019-02-07 17:05:56 -0500 |
commit | 90cfa82fecd3304c741958a92a8f39b468f865c6 (patch) | |
tree | f9d53d6b711eb10efe26c7c542b0353335e80aa6 /src/mongo/db | |
parent | fd3a55180b5af9dfce2214326b70b75c6567f838 (diff) | |
download | mongo-90cfa82fecd3304c741958a92a8f39b468f865c6.tar.gz |
SERVER-39292 Do not evaluate failpoint twice per operation when multiple options specified
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/commands.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp index bd307d6a7f6..90b16d671d1 100644 --- a/src/mongo/db/commands.cpp +++ b/src/mongo/db/commands.cpp @@ -500,21 +500,27 @@ bool CommandHelpers::shouldActivateFailCommandFailPoint(const BSONObj& data, } void CommandHelpers::evaluateFailCommandFailPoint(OperationContext* opCtx, StringData commandName) { + bool closeConnection, hasErrorCode; + long long errorCode; + MONGO_FAIL_POINT_BLOCK_IF(failCommand, data, [&](const BSONObj& data) { + closeConnection = data.hasField("closeConnection") && + bsonExtractBooleanField(data, "closeConnection", &closeConnection).isOK() && + closeConnection; + hasErrorCode = data.hasField("errorCode") && + bsonExtractIntegerField(data, "errorCode", &errorCode).isOK(); + return shouldActivateFailCommandFailPoint(data, commandName, opCtx->getClient()) && - (data.hasField("closeConnection") || data.hasField("errorCode")); + (closeConnection || hasErrorCode); }) { - bool closeConnection; - if (bsonExtractBooleanField(data.getData(), "closeConnection", &closeConnection).isOK() && - closeConnection) { + if (closeConnection) { opCtx->getClient()->session()->end(); log() << "Failing command '" << commandName << "' via 'failCommand' failpoint. Action: closing connection."; uasserted(50985, "Failing command due to 'failCommand' failpoint"); } - long long errorCode; - if (bsonExtractIntegerField(data.getData(), "errorCode", &errorCode).isOK()) { + if (hasErrorCode) { log() << "Failing command '" << commandName << "' via 'failCommand' failpoint. Action: returning error code " << errorCode << "."; |