diff options
author | Alex Li <alex.li@mongodb.com> | 2022-11-15 14:05:51 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-11-15 14:37:46 +0000 |
commit | 46c324dbbac641206a010e0c2b8cbea24dbd3b4e (patch) | |
tree | 041fb1b5784ac36cadd97e766e7cb3a89b2a8cb1 | |
parent | 55b79109bc21b54c629ef2489f02f10c9c1db4c0 (diff) | |
download | mongo-46c324dbbac641206a010e0c2b8cbea24dbd3b4e.tar.gz |
SERVER-70206 Remove getLastError command
19 files changed, 7 insertions, 175 deletions
diff --git a/jstests/core/views/views_all_commands.js b/jstests/core/views/views_all_commands.js index 3644f3a7c72..16c8b70e67e 100644 --- a/jstests/core/views/views_all_commands.js +++ b/jstests/core/views/views_all_commands.js @@ -386,7 +386,6 @@ let viewsCommandTests = { getDefaultRWConcern: {skip: isUnrelated}, getDiagnosticData: {skip: isUnrelated}, getFreeMonitoringStatus: {skip: isUnrelated}, - getLastError: {skip: isUnrelated}, getLog: {skip: isUnrelated}, getMore: { setup: function(conn) { diff --git a/jstests/libs/override_methods/inject_security_token.js b/jstests/libs/override_methods/inject_security_token.js index 6403417f05b..3fd20bbb12c 100644 --- a/jstests/libs/override_methods/inject_security_token.js +++ b/jstests/libs/override_methods/inject_security_token.js @@ -122,8 +122,6 @@ const kCmdsAllowedWithSecurityToken = new Set([ `findandmodify`, `geoNear`, `geoSearch`, - `getLastError`, - `getlasterror`, `getMore`, `getParameter`, `hello`, diff --git a/jstests/replsets/all_commands_downgrading_to_upgraded.js b/jstests/replsets/all_commands_downgrading_to_upgraded.js index b586cf849c5..f519e2019f6 100644 --- a/jstests/replsets/all_commands_downgrading_to_upgraded.js +++ b/jstests/replsets/all_commands_downgrading_to_upgraded.js @@ -649,12 +649,6 @@ const allCommands = { isAdminCommand: true, command: {getFreeMonitoringStatus: 1}, }, - getLastError: { - isAdminCommand: true, - command: {getLastError: 1}, - expectFailure: true, - expectedErrorCode: 5739000 // getLastError is not supported anymore. - }, getLog: { isAdminCommand: true, command: {getLog: "global"}, diff --git a/jstests/replsets/db_reads_while_recovering_all_commands.js b/jstests/replsets/db_reads_while_recovering_all_commands.js index 42481e7dd0d..76baf073c30 100644 --- a/jstests/replsets/db_reads_while_recovering_all_commands.js +++ b/jstests/replsets/db_reads_while_recovering_all_commands.js @@ -247,7 +247,6 @@ const allCommands = { getDefaultRWConcern: {skip: isNotAUserDataRead}, getDiagnosticData: {skip: isNotAUserDataRead}, getFreeMonitoringStatus: {skip: isNotAUserDataRead}, - getLastError: {skip: isPrimaryOnly}, getLog: {skip: isNotAUserDataRead}, getMore: { command: {getMore: NumberLong(123), collection: collName}, diff --git a/jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js b/jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js index dc6752874ab..0680047c874 100644 --- a/jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js +++ b/jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js @@ -608,7 +608,6 @@ TenantMigrationConcurrentWriteUtil.testCases = { getDefaultRWConcern: {skip: isNotRunOnUserDatabase}, getDiagnosticData: {skip: isNotRunOnUserDatabase}, getFreeMonitoringStatus: {skip: isNotRunOnUserDatabase}, - getLastError: {skip: isNotWriteCommand}, getLog: {skip: isNotRunOnUserDatabase}, getMore: {skip: isNotWriteCommand}, getParameter: {skip: isNotRunOnUserDatabase}, diff --git a/jstests/sharding/database_versioning_all_commands.js b/jstests/sharding/database_versioning_all_commands.js index 7e9d5f0c0e6..855271fdfca 100644 --- a/jstests/sharding/database_versioning_all_commands.js +++ b/jstests/sharding/database_versioning_all_commands.js @@ -490,7 +490,6 @@ let testCases = { getCmdLineOpts: {skip: "executes locally on mongos (not sent to any remote node)"}, getDefaultRWConcern: {skip: "executes locally on mongos (not sent to any remote node)"}, getDiagnosticData: {skip: "executes locally on mongos (not sent to any remote node)"}, - getLastError: {skip: "does not forward command to primary shard"}, getLog: {skip: "executes locally on mongos (not sent to any remote node)"}, getMore: {skip: "requires a previously established cursor"}, getParameter: {skip: "executes locally on mongos (not sent to any remote node)"}, @@ -746,6 +745,10 @@ const st = new ShardingTest({shards: 2, mongos: 2}); const listCommandsRes = st.s0.adminCommand({listCommands: 1}); assert.commandWorked(listCommandsRes); +print("--------------------------------------------"); +for (let command of Object.keys(listCommandsRes.commands)) { + print(command); +} (() => { // Validate test cases for all commands. diff --git a/jstests/sharding/libs/last_lts_mongod_commands.js b/jstests/sharding/libs/last_lts_mongod_commands.js index aec5cf7c4bb..8b71181063d 100644 --- a/jstests/sharding/libs/last_lts_mongod_commands.js +++ b/jstests/sharding/libs/last_lts_mongod_commands.js @@ -8,6 +8,7 @@ const commandsRemovedFromMongodSinceLastLTS = [ "_configsvrRepairShardedCollectionChunksHistory", "mapreduce.shardedfinish", "availableQueryOptions", // TODO SERVER-67689: remove this once 7.0 becomes last-lts + "getLastError", ]; // These commands were added in mongod since the last LTS version, so will not appear in the // listCommands output of a last LTS version mongod. We will allow these commands to have a diff --git a/jstests/sharding/libs/last_lts_mongos_commands.js b/jstests/sharding/libs/last_lts_mongos_commands.js index 3cc0f35b22f..f5879468747 100644 --- a/jstests/sharding/libs/last_lts_mongos_commands.js +++ b/jstests/sharding/libs/last_lts_mongos_commands.js @@ -7,6 +7,7 @@ const commandsRemovedFromMongosSinceLastLTS = [ "repairShardedCollectionChunksHistory", // last-continuos "availableQueryOptions", // TODO SERVER-67689: remove this once 7.0 becomes last-lts + "getLastError", ]; // These commands were added in mongos since the last LTS version, so will not appear in the diff --git a/jstests/sharding/libs/mongos_api_params_util.js b/jstests/sharding/libs/mongos_api_params_util.js index c920509c36d..156a5888e80 100644 --- a/jstests/sharding/libs/mongos_api_params_util.js +++ b/jstests/sharding/libs/mongos_api_params_util.js @@ -587,10 +587,6 @@ let MongosAPIParametersUtil = (function() { commandName: "getDiagnosticData", skip: "executes locally on mongos (not sent to any remote node)" }, - { - commandName: "getLastError", - skip: "executes locally on mongos (not sent to any remote node)" - }, {commandName: "getLog", skip: "executes locally on mongos (not sent to any remote node)"}, { commandName: "getMore", diff --git a/jstests/sharding/read_write_concern_defaults_application.js b/jstests/sharding/read_write_concern_defaults_application.js index 33b8f9fe439..be64b71f359 100644 --- a/jstests/sharding/read_write_concern_defaults_application.js +++ b/jstests/sharding/read_write_concern_defaults_application.js @@ -481,7 +481,6 @@ let testCases = { getDefaultRWConcern: {skip: "does not accept read or write concern"}, getDiagnosticData: {skip: "does not accept read or write concern"}, getFreeMonitoringStatus: {skip: "does not accept read or write concern"}, - getLastError: {skip: "does not accept read or write concern"}, getLog: {skip: "does not accept read or write concern"}, getMore: {skip: "does not accept read or write concern"}, getParameter: {skip: "does not accept read or write concern"}, diff --git a/jstests/sharding/safe_secondary_reads_drop_recreate.js b/jstests/sharding/safe_secondary_reads_drop_recreate.js index 5bc2942521a..2fec97d2fcf 100644 --- a/jstests/sharding/safe_secondary_reads_drop_recreate.js +++ b/jstests/sharding/safe_secondary_reads_drop_recreate.js @@ -210,7 +210,6 @@ let testCases = { getCmdLineOpts: {skip: "does not return user data"}, getDefaultRWConcern: {skip: "does not return user data"}, getDiagnosticData: {skip: "does not return user data"}, - getLastError: {skip: "primary only"}, getLog: {skip: "does not return user data"}, getMore: {skip: "shard version already established"}, getParameter: {skip: "does not return user data"}, diff --git a/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js b/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js index 254127b83d1..aca07645c32 100644 --- a/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js +++ b/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js @@ -243,7 +243,6 @@ let testCases = { getCmdLineOpts: {skip: "does not return user data"}, getDefaultRWConcern: {skip: "does not return user data"}, getDiagnosticData: {skip: "does not return user data"}, - getLastError: {skip: "primary only"}, getLog: {skip: "does not return user data"}, getMore: {skip: "shard version already established"}, getParameter: {skip: "does not return user data"}, diff --git a/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js b/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js index dfb02ac3f7d..6a2035d91e8 100644 --- a/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js +++ b/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js @@ -215,7 +215,6 @@ let testCases = { getCmdLineOpts: {skip: "does not return user data"}, getDefaultRWConcern: {skip: "does not return user data"}, getDiagnosticData: {skip: "does not return user data"}, - getLastError: {skip: "primary only"}, getLog: {skip: "does not return user data"}, getMore: {skip: "shard version already established"}, getParameter: {skip: "does not return user data"}, diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript index 052dfba1186..3dd709d03e7 100644 --- a/src/mongo/db/commands/SConscript +++ b/src/mongo/db/commands/SConscript @@ -308,7 +308,6 @@ env.Library( "explain_cmd.cpp", "find_and_modify.cpp", "find_cmd.cpp", - "get_last_error.cpp", "getmore_cmd.cpp", "http_client.cpp", 'http_client.idl', diff --git a/src/mongo/db/commands/get_last_error.cpp b/src/mongo/db/commands/get_last_error.cpp deleted file mode 100644 index 7ef994bd772..00000000000 --- a/src/mongo/db/commands/get_last_error.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the Server Side Public License in all respects for - * all of the code used other than as permitted herein. If you modify file(s) - * with this exception, you may extend this exception to your version of the - * file(s), but you are not obligated to do so. If you do not wish to do so, - * delete this exception statement from your version. If you delete this - * exception statement from all source files in the program, then also delete - * it in the license file. - */ - - -#include "mongo/platform/basic.h" - -#include "mongo/db/client.h" -#include "mongo/db/commands.h" -#include "mongo/rpc/check_allowed_op_query_cmd.h" - -#define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kCommand - - -namespace mongo { -namespace { - -class CmdGetLastError : public BasicCommand { -public: - CmdGetLastError() : BasicCommand("getLastError", "getlasterror") {} - virtual bool supportsWriteConcern(const BSONObj& cmd) const override { - return false; - } - AllowedOnSecondary secondaryAllowed(ServiceContext*) const override { - return AllowedOnSecondary::kAlways; - } - - Status checkAuthForOperation(OperationContext*, - const DatabaseName&, - const BSONObj&) const override { - return Status::OK(); - } - - bool requiresAuth() const override { - return false; - } - - std::string help() const override { - return "no longer supported"; - } - - bool run(OperationContext* opCtx, - const DatabaseName&, - const BSONObj& cmdObj, - BSONObjBuilder& result) override { - uasserted(5739000, "getLastError command is not supported"); - return false; - } - -} cmdGetLastError; - -} // namespace -} // namespace mongo diff --git a/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp b/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp index b7d15792fc4..e8c5fabc23f 100644 --- a/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp +++ b/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp @@ -579,7 +579,6 @@ TEST_F(MongodbCAPITest, RunListCommands) { "explain", "find", "findAndModify", - "getLastError", "getMore", "getParameter", "httpClientRequest", diff --git a/src/mongo/rpc/op_legacy_integration_test.cpp b/src/mongo/rpc/op_legacy_integration_test.cpp index 953dc19195e..7806e1aa866 100644 --- a/src/mongo/rpc/op_legacy_integration_test.cpp +++ b/src/mongo/rpc/op_legacy_integration_test.cpp @@ -134,8 +134,7 @@ TEST(OpLegacy, GetLastError) { // 'getLastError' command is no longer supported and will always fail. auto status = getStatusFromCommandResult(replyObj); ASSERT_NOT_OK(status) << replyObj; - const auto expectedCode = conn->isMongos() ? 5739001 : 5739000; - ASSERT_EQ(status.code(), expectedCode) << replyObj; + ASSERT_EQ(status.code(), ErrorCodes::CommandNotFound) << replyObj; } TEST(OpLegacy, UnsupportedWriteOps) { diff --git a/src/mongo/s/commands/SConscript b/src/mongo/s/commands/SConscript index 4493a22e02d..a26a28f9858 100644 --- a/src/mongo/s/commands/SConscript +++ b/src/mongo/s/commands/SConscript @@ -56,7 +56,6 @@ env.Library( 'cluster_fsync_cmd.cpp', 'cluster_ftdc_commands.cpp', 'cluster_get_cluster_parameter_cmd.cpp', - 'cluster_get_last_error_cmd.cpp', 'cluster_get_shard_version_cmd.cpp', 'cluster_getmore_cmd_s.cpp', 'cluster_hello_cmd.cpp', diff --git a/src/mongo/s/commands/cluster_get_last_error_cmd.cpp b/src/mongo/s/commands/cluster_get_last_error_cmd.cpp deleted file mode 100644 index 2b7f8c322ff..00000000000 --- a/src/mongo/s/commands/cluster_get_last_error_cmd.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the Server Side Public License in all respects for - * all of the code used other than as permitted herein. If you modify file(s) - * with this exception, you may extend this exception to your version of the - * file(s), but you are not obligated to do so. If you do not wish to do so, - * delete this exception statement from your version. If you delete this - * exception statement from all source files in the program, then also delete - * it in the license file. - */ - -#include "mongo/platform/basic.h" - -#include "mongo/db/commands.h" -#include "mongo/rpc/check_allowed_op_query_cmd.h" - -namespace mongo { -namespace { - -class GetLastErrorCmd : public BasicCommand { -public: - GetLastErrorCmd() : BasicCommand("getLastError", "getlasterror") {} - - bool supportsWriteConcern(const BSONObj& cmd) const override { - return false; - } - - AllowedOnSecondary secondaryAllowed(ServiceContext*) const override { - return AllowedOnSecondary::kAlways; - } - - std::string help() const override { - return "no longer supported"; - } - - Status checkAuthForOperation(OperationContext*, - const DatabaseName&, - const BSONObj&) const override { - return Status::OK(); // No auth required - } - - bool requiresAuth() const override { - return false; - } - - bool run(OperationContext*, const DatabaseName&, const BSONObj&, BSONObjBuilder&) override { - uasserted(5739001, "getLastError command is not supported"); - return false; - } - -} cmdGetLastError; - -} // namespace -} // namespace mongo |