diff options
author | Louis Williams <louis.williams@mongodb.com> | 2018-08-06 14:52:37 -0400 |
---|---|---|
committer | Louis Williams <louis.williams@mongodb.com> | 2018-08-13 13:10:34 -0400 |
commit | f899002aade5d8fa1cbf0b1ad79e3088b8d4b050 (patch) | |
tree | eb8442e167590ca9043e52e2dc7f980f3f5f1e21 /src/mongo/db | |
parent | f46d77c794e0da816ab4c93b0cb6ace2b771a428 (diff) | |
download | mongo-f899002aade5d8fa1cbf0b1ad79e3088b8d4b050.tar.gz |
SERVER-36208 Remove repairDatabase server command and shell helper
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/auth/action_types.txt | 1 | ||||
-rw-r--r-- | src/mongo/db/auth/role_graph_builtin_roles.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/commands/SConscript | 1 | ||||
-rw-r--r-- | src/mongo/db/commands/dbcommands.cpp | 87 | ||||
-rw-r--r-- | src/mongo/db/commands/dbcommands_d.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/storage/storage_engine.h | 2 | ||||
-rw-r--r-- | src/mongo/db/storage/storage_options.h | 3 |
7 files changed, 13 insertions, 86 deletions
diff --git a/src/mongo/db/auth/action_types.txt b/src/mongo/db/auth/action_types.txt index c59f4c2318d..e5a5d7dc47e 100644 --- a/src/mongo/db/auth/action_types.txt +++ b/src/mongo/db/auth/action_types.txt @@ -89,7 +89,6 @@ "removeShard", "renameCollection", # Not used for permissions checks, but to id the event in logs. "renameCollectionSameDB", -"repairDatabase", "replSetConfigure", "replSetGetConfig", "replSetGetStatus", diff --git a/src/mongo/db/auth/role_graph_builtin_roles.cpp b/src/mongo/db/auth/role_graph_builtin_roles.cpp index 90c6a6e97f2..8f096ac641d 100644 --- a/src/mongo/db/auth/role_graph_builtin_roles.cpp +++ b/src/mongo/db/auth/role_graph_builtin_roles.cpp @@ -170,7 +170,6 @@ MONGO_INITIALIZER(AuthorizationBuiltinRoles)(InitializerContext* context) { << ActionType::planCacheWrite << ActionType::reIndex << ActionType::renameCollectionSameDB // read_write gets this also - << ActionType::repairDatabase << ActionType::storageDetails << ActionType::validate; @@ -225,8 +224,7 @@ MONGO_INITIALIZER(AuthorizationBuiltinRoles)(InitializerContext* context) { // hostManager role actions that target the database resource hostManagerRoleDatabaseActions - << ActionType::killCursors - << ActionType::repairDatabase; + << ActionType::killCursors; // clusterManager role actions that target the cluster resource diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript index 2e0ba44d04a..1cd906b2382 100644 --- a/src/mongo/db/commands/SConscript +++ b/src/mongo/db/commands/SConscript @@ -241,7 +241,6 @@ env.Library( '$BUILD_DIR/mongo/db/ops/write_ops_exec', '$BUILD_DIR/mongo/db/pipeline/mongod_process_interface', '$BUILD_DIR/mongo/db/query_exec', - '$BUILD_DIR/mongo/db/repair_database', '$BUILD_DIR/mongo/db/rw_concern_d', '$BUILD_DIR/mongo/db/stats/counters', '$BUILD_DIR/mongo/db/storage/storage_engine_common', diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp index 56d28ebb53a..d51ff6ae1e0 100644 --- a/src/mongo/db/commands/dbcommands.cpp +++ b/src/mongo/db/commands/dbcommands.cpp @@ -79,7 +79,6 @@ #include "mongo/db/query/internal_plans.h" #include "mongo/db/query/query_planner.h" #include "mongo/db/read_concern.h" -#include "mongo/db/repair_database.h" #include "mongo/db/repl/optime.h" #include "mongo/db/repl/read_concern_args.h" #include "mongo/db/repl/repl_client_info.h" @@ -167,31 +166,28 @@ public: } cmdDropDatabase; +static const char* repairRemovedMessage = + "This command has been removed. If you would like to compact your data, use the 'compact' " + "command. If you would like to rebuild indexes, use the 'reIndex' command. If you need to " + "recover data, please see the documentation for repairing your database offline: " + "https://dochub.mongodb.org/core/repair"; + class CmdRepairDatabase : public ErrmsgCommandDeprecated { public: AllowedOnSecondary secondaryAllowed(ServiceContext*) const override { return AllowedOnSecondary::kAlways; } virtual bool maintenanceMode() const { - return true; + return false; } + std::string help() const override { - return "repair database. also compacts. note: slow."; + return repairRemovedMessage; } - - virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } - virtual void addRequiredPrivileges(const std::string& dbname, - const BSONObj& cmdObj, - std::vector<Privilege>* out) const { - ActionSet actions; - actions.addAction(ActionType::repairDatabase); - out->push_back(Privilege(ResourcePattern::forDatabaseName(dbname), actions)); - } - CmdRepairDatabase() : ErrmsgCommandDeprecated("repairDatabase") {} bool errmsgRun(OperationContext* opCtx, @@ -199,70 +195,9 @@ public: const BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result) { - BSONElement e = cmdObj.firstElement(); - if (e.numberInt() != 1) { - errmsg = "bad option"; - return false; - } - // Closing a database requires a global lock. - Lock::GlobalWrite lk(opCtx); - auto db = DatabaseHolder::getDatabaseHolder().get(opCtx, dbname); - if (db) { - if (db->isDropPending(opCtx)) { - uasserted(ErrorCodes::DatabaseDropPending, - str::stream() << "Cannot repair database " << dbname - << " since it is pending being dropped."); - } - } else { - // If the name doesn't make an exact match, check for a case insensitive match. - std::set<std::string> otherCasing = - DatabaseHolder::getDatabaseHolder().getNamesWithConflictingCasing(dbname); - if (otherCasing.empty()) { - // Database doesn't exist. Treat this as a success (historical behavior). - return true; - } - - // Database exists with a differing case. Treat this as an error. Report the casing - // conflict. - errmsg = str::stream() << "Database exists with a different case. Given: `" << dbname - << "` Found: `" << *otherCasing.begin() << "`"; - return false; - } - - // TODO (Kal): OldClientContext legacy, needs to be removed - { - CurOp::get(opCtx)->ensureStarted(); - stdx::lock_guard<Client> lk(*opCtx->getClient()); - CurOp::get(opCtx)->setNS_inlock(dbname); - } - - log() << "repairDatabase " << dbname; - BackgroundOperation::assertNoBgOpInProgForDb(dbname); - - uassert(ErrorCodes::BadValue, - "preserveClonedFilesOnFailure not supported", - !cmdObj.getField("preserveClonedFilesOnFailure").trueValue()); - uassert(ErrorCodes::BadValue, - "backupOriginalFiles not supported", - !cmdObj.getField("backupOriginalFiles").trueValue()); - - { - // Conceal UUIDCatalog changes for the duration of repairDatabase so that calls to - // UUIDCatalog::lookupNSSByUUID do not cause spurious NamespaceNotFound errors while - // repairDatabase makes updates. - ConcealUUIDCatalogChangesBlock cucc(opCtx); - - StorageEngine* engine = getGlobalServiceContext()->getStorageEngine(); - repl::UnreplicatedWritesBlock uwb(opCtx); - Status status = repairDatabase(opCtx, engine, dbname); - - // Open database before returning - DatabaseHolder::getDatabaseHolder().openDb(opCtx, dbname); - uassertStatusOK(status); - } - - return true; + uasserted(ErrorCodes::CommandNotFound, repairRemovedMessage); + return false; } } cmdRepairDatabase; diff --git a/src/mongo/db/commands/dbcommands_d.cpp b/src/mongo/db/commands/dbcommands_d.cpp index ad8cad49523..ec92a4c5a60 100644 --- a/src/mongo/db/commands/dbcommands_d.cpp +++ b/src/mongo/db/commands/dbcommands_d.cpp @@ -80,7 +80,6 @@ #include "mongo/db/query/internal_plans.h" #include "mongo/db/query/query_planner.h" #include "mongo/db/read_concern.h" -#include "mongo/db/repair_database.h" #include "mongo/db/repl/optime.h" #include "mongo/db/repl/read_concern_args.h" #include "mongo/db/repl/repl_client_info.h" diff --git a/src/mongo/db/storage/storage_engine.h b/src/mongo/db/storage/storage_engine.h index 0fcd1bbb61c..1f97ad2d0d1 100644 --- a/src/mongo/db/storage/storage_engine.h +++ b/src/mongo/db/storage/storage_engine.h @@ -281,8 +281,6 @@ public: * * Generally, this method should not be called directly except by the repairDatabase() * free function. - * - * NOTE: MMAPv1 does not support this method and has its own repairDatabase() method. */ virtual Status repairRecordStore(OperationContext* opCtx, const std::string& ns) = 0; diff --git a/src/mongo/db/storage/storage_options.h b/src/mongo/db/storage/storage_options.h index 144dd1eb77b..8d18506053c 100644 --- a/src/mongo/db/storage/storage_options.h +++ b/src/mongo/db/storage/storage_options.h @@ -70,8 +70,7 @@ struct StorageGlobalParams { bool upgrade; // --repair - // Runs a repair routine on all databases. This is equivalent to shutting down and - // running the repairDatabase database command on all databases. + // Runs a repair routine on all databases. bool repair; bool dur; // --dur durability (now --journal) |