summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
authorA. Jesse Jiryu Davis <jesse@mongodb.com>2021-05-04 19:29:17 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-05-13 17:48:10 +0000
commit500a405a5ce235507f56fb47e8d5d4b368d3458d (patch)
treeeecb1020c3049a816d28ffd5461b8d3ecab8686a /src/mongo/db/commands
parent2070fc76b3604f8c04997862159b0fc721eeb465 (diff)
downloadmongo-500a405a5ce235507f56fb47e8d5d4b368d3458d.tar.gz
SERVER-56550 Require consistent API params in getMore and txns
Transaction-continuing commands must use the same API parameters as the transaction's first command (it is no longer optional), and similarly getMore must use the same as the cursor-creating command.
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r--src/mongo/db/commands/getmore_cmd.cpp17
-rw-r--r--src/mongo/db/commands/user_management_commands.cpp6
2 files changed, 7 insertions, 16 deletions
diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp
index 9624761a5e9..1772d5b3a25 100644
--- a/src/mongo/db/commands/getmore_cmd.cpp
+++ b/src/mongo/db/commands/getmore_cmd.cpp
@@ -225,18 +225,11 @@ void setUpOperationContextStateForGetMore(OperationContext* opCtx,
opCtx->setWriteConcern(cursor.getWriteConcernOptions());
auto apiParamsFromClient = APIParameters::get(opCtx);
- // TODO (SERVER-56550): Do this check even if !apiParamsFromClient.getParamsPassed().
- if (apiParamsFromClient.getParamsPassed()) {
- uassert(
- ErrorCodes::APIMismatchError,
- "API param conflict: getMore used params {}, the cursor-creating command used {}"_format(
- apiParamsFromClient.toBSON().toString(),
- cursor.getAPIParameters().toBSON().toString()),
- apiParamsFromClient == cursor.getAPIParameters());
- }
-
- // TODO (SERVER-56550): Remove.
- APIParameters::get(opCtx) = cursor.getAPIParameters();
+ uassert(
+ ErrorCodes::APIMismatchError,
+ "API parameter mismatch: getMore used params {}, the cursor-creating command used {}"_format(
+ apiParamsFromClient.toBSON().toString(), cursor.getAPIParameters().toBSON().toString()),
+ apiParamsFromClient == cursor.getAPIParameters());
setUpOperationDeadline(opCtx, cursor, cmd, disableAwaitDataFailpointActive);
diff --git a/src/mongo/db/commands/user_management_commands.cpp b/src/mongo/db/commands/user_management_commands.cpp
index d8c7582ad16..9c42dec4997 100644
--- a/src/mongo/db/commands/user_management_commands.cpp
+++ b/src/mongo/db/commands/user_management_commands.cpp
@@ -885,10 +885,8 @@ private:
_sessionInfo.serialize(cmdBuilder);
}
- if (_state == TransactionState::kInit || !_isReplSet) {
- // Set a default apiVersion for all UMC commands
- cmdBuilder->append("apiVersion", kOne);
- }
+ // Set a default apiVersion for all UMC commands
+ cmdBuilder->append("apiVersion", kOne);
auto svcCtx = _client->getServiceContext();
auto sep = svcCtx->getServiceEntryPoint();