diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2021-05-10 18:01:22 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-05-28 16:56:34 +0000 |
commit | 4a311668ac834b6e363a44c9f00cad9d4790288f (patch) | |
tree | 473d9d3711e765720be7f3dc0f0c332c05c5f6ae /src/mongo/db/commands/getmore_cmd.cpp | |
parent | 1bcdc63ff24bbc1b3c8167a0ab44bc048de001ed (diff) | |
download | mongo-4a311668ac834b6e363a44c9f00cad9d4790288f.tar.gz |
SERVER-50549 transform state-changing errors returned by mongos
Diffstat (limited to 'src/mongo/db/commands/getmore_cmd.cpp')
-rw-r--r-- | src/mongo/db/commands/getmore_cmd.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp index 88eb60eb201..662038b4993 100644 --- a/src/mongo/db/commands/getmore_cmd.cpp +++ b/src/mongo/db/commands/getmore_cmd.cpp @@ -36,6 +36,7 @@ #include <memory> #include <string> +#include "mongo/bson/util/bson_extract.h" #include "mongo/db/api_parameters.h" #include "mongo/db/auth/authorization_checks.h" #include "mongo/db/auth/authorization_session.h" @@ -64,6 +65,7 @@ #include "mongo/db/stats/resource_consumption_metrics.h" #include "mongo/db/stats/top.h" #include "mongo/logv2/log.h" +#include "mongo/rpc/rewrite_state_change_errors.h" #include "mongo/s/chunk_version.h" #include "mongo/util/fail_point.h" #include "mongo/util/scopeguard.h" @@ -567,7 +569,11 @@ public: // If the 'failGetMoreAfterCursorCheckout' failpoint is enabled, throw an exception with // the given 'errorCode' value, or ErrorCodes::InternalError if 'errorCode' is omitted. failGetMoreAfterCursorCheckout.executeIf( - [](const BSONObj& data) { + [&](const BSONObj& data) { + if (bool b; + !bsonExtractBooleanField(data, "allowRewriteStateChange", &b).isOK() || !b) + rpc::RewriteStateChangeErrors::setEnabled(opCtx, false); + auto errorCode = (data["errorCode"] ? data["errorCode"].safeNumberLong() : ErrorCodes::InternalError); uasserted(errorCode, "Hit the 'failGetMoreAfterCursorCheckout' failpoint"); |