summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Williams <louis.williams@mongodb.com>2018-08-06 14:52:37 -0400
committerLouis Williams <louis.williams@mongodb.com>2018-08-13 13:10:34 -0400
commitf899002aade5d8fa1cbf0b1ad79e3088b8d4b050 (patch)
treeeb8442e167590ca9043e52e2dc7f980f3f5f1e21
parentf46d77c794e0da816ab4c93b0cb6ace2b771a428 (diff)
downloadmongo-f899002aade5d8fa1cbf0b1ad79e3088b8d4b050.tar.gz
SERVER-36208 Remove repairDatabase server command and shell helper
-rw-r--r--buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough.yml3
-rw-r--r--buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough_auth.yml3
-rw-r--r--buildscripts/resmokeconfig/suites/replica_sets_multi_stmt_txn_jscore_passthrough.yml1
-rw-r--r--buildscripts/resmokeconfig/suites/sharded_causally_consistent_jscore_passthrough.yml3
-rw-r--r--buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml3
-rw-r--r--buildscripts/resmokeconfig/suites/sharding_jscore_op_query_passthrough.yml3
-rw-r--r--buildscripts/resmokeconfig/suites/sharding_jscore_passthrough.yml3
-rw-r--r--jstests/auth/lib/commands_lib.js36
-rw-r--r--jstests/core/repair_database.js53
-rw-r--r--jstests/core/repair_database_input_validation.js58
-rw-r--r--jstests/core/repair_server12955.js23
-rw-r--r--jstests/core/views/views_all_commands.js2
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/major_version_upgrade.js3
-rw-r--r--jstests/noPassthrough/index_version_autoupgrade.js7
-rw-r--r--jstests/noPassthrough/read_majority.js10
-rw-r--r--jstests/noPassthrough/repair2.js47
-rw-r--r--jstests/noPassthroughWithMongod/repair_unsupported_options.js10
-rw-r--r--jstests/replsets/drop_databases_two_phase.js4
-rw-r--r--jstests/replsets/read_committed_with_catalog_changes.js11
-rw-r--r--jstests/sharding/safe_secondary_reads_drop_recreate.js1
-rw-r--r--jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js1
-rw-r--r--jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js1
-rw-r--r--src/mongo/db/auth/action_types.txt1
-rw-r--r--src/mongo/db/auth/role_graph_builtin_roles.cpp4
-rw-r--r--src/mongo/db/commands/SConscript1
-rw-r--r--src/mongo/db/commands/dbcommands.cpp87
-rw-r--r--src/mongo/db/commands/dbcommands_d.cpp1
-rw-r--r--src/mongo/db/storage/storage_engine.h2
-rw-r--r--src/mongo/db/storage/storage_options.h3
-rw-r--r--src/mongo/shell/db.js10
30 files changed, 14 insertions, 381 deletions
diff --git a/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough.yml
index 7f9b68e62b2..e61187e6882 100644
--- a/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough.yml
@@ -39,9 +39,6 @@ selector:
- jstests/core/index9.js # "local" database.
- jstests/core/profile*.js # profiling.
- jstests/core/queryoptimizera.js # "local" database.
- - jstests/core/repair_database.js # repairDatabase
- - jstests/core/repair_database_input_validation.js # repairDatabase
- - jstests/core/repair_server12955.js # repairDatabase
- jstests/core/stages*.js # stageDebug.
# The following tests fail because mongos behaves differently from mongod when testing certain
# functionality. The differences are in a comment next to the failing test.
diff --git a/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough_auth.yml b/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough_auth.yml
index 64969e5d3d5..5d11f8ffe76 100644
--- a/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough_auth.yml
+++ b/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough_auth.yml
@@ -52,9 +52,6 @@ selector:
- jstests/core/index9.js # "local" database.
- jstests/core/profile*.js # profiling.
- jstests/core/queryoptimizera.js # "local" database.
- - jstests/core/repair_database.js # repairDatabase
- - jstests/core/repair_database_input_validation.js # repairDatabase
- - jstests/core/repair_server12955.js # repairDatabase
- jstests/core/stages*.js # stageDebug.
# The following tests fail because mongos behaves differently from mongod when testing certain
# functionality. The differences are in a comment next to the failing test.
diff --git a/buildscripts/resmokeconfig/suites/replica_sets_multi_stmt_txn_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/replica_sets_multi_stmt_txn_jscore_passthrough.yml
index 1ee3e8a309c..fead09408d2 100644
--- a/buildscripts/resmokeconfig/suites/replica_sets_multi_stmt_txn_jscore_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/replica_sets_multi_stmt_txn_jscore_passthrough.yml
@@ -166,7 +166,6 @@ selector:
- jstests/core/dbref1.js
- jstests/core/dbref2.js
- jstests/core/ref3.js
- - jstests/core/repair_database.js
- jstests/core/update3.js
- jstests/core/rename3.js
diff --git a/buildscripts/resmokeconfig/suites/sharded_causally_consistent_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/sharded_causally_consistent_jscore_passthrough.yml
index 8df91eab2f0..dc09210bd2e 100644
--- a/buildscripts/resmokeconfig/suites/sharded_causally_consistent_jscore_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/sharded_causally_consistent_jscore_passthrough.yml
@@ -37,9 +37,6 @@ selector:
- jstests/core/profile*.js # profiling.
- jstests/core/queryoptimizera.js # "local" database.
- jstests/core/rename*.js # renameCollection.
- - jstests/core/repair_database.js # repairDatabase
- - jstests/core/repair_database_input_validation.js # repairDatabase
- - jstests/core/repair_server12955.js # repairDatabase
- jstests/core/stages*.js # stageDebug.
- jstests/core/tailable_cursor_invalidation.js # capped collections.
- jstests/core/tailable_getmore_batch_size.js # capped collections.
diff --git a/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml
index 2d9980907f9..15faab4414f 100644
--- a/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml
@@ -37,9 +37,6 @@ selector:
- jstests/core/profile*.js # profiling.
- jstests/core/queryoptimizera.js # "local" database.
- jstests/core/rename*.js # renameCollection.
- - jstests/core/repair_database.js # repairDatabase
- - jstests/core/repair_database_input_validation.js # repairDatabase
- - jstests/core/repair_server12955.js # repairDatabase
- jstests/core/stages*.js # stageDebug.
- jstests/core/startup_log.js # "local" database.
- jstests/core/tailable_cursor_invalidation.js # capped collections.
diff --git a/buildscripts/resmokeconfig/suites/sharding_jscore_op_query_passthrough.yml b/buildscripts/resmokeconfig/suites/sharding_jscore_op_query_passthrough.yml
index 75f7aec7794..62748d9647b 100644
--- a/buildscripts/resmokeconfig/suites/sharding_jscore_op_query_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/sharding_jscore_op_query_passthrough.yml
@@ -36,9 +36,6 @@ selector:
- jstests/core/notablescan.js # notablescan.
- jstests/core/profile*.js # profiling.
- jstests/core/queryoptimizera.js # "local" database.
- - jstests/core/repair_database.js # repairDatabase
- - jstests/core/repair_database_input_validation.js # repairDatabase
- - jstests/core/repair_server12955.js # repairDatabase
- jstests/core/stages*.js # stageDebug.
- jstests/core/startup_log.js # "local" database.
- jstests/core/top.js # top.
diff --git a/buildscripts/resmokeconfig/suites/sharding_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/sharding_jscore_passthrough.yml
index 62b5a9eacb7..9cb9e910cb3 100644
--- a/buildscripts/resmokeconfig/suites/sharding_jscore_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/sharding_jscore_passthrough.yml
@@ -36,9 +36,6 @@ selector:
- jstests/core/notablescan.js # notablescan.
- jstests/core/profile*.js # profiling.
- jstests/core/queryoptimizera.js # "local" database.
- - jstests/core/repair_database.js # repairDatabase
- - jstests/core/repair_database_input_validation.js # repairDatabase
- - jstests/core/repair_server12955.js # repairDatabase
- jstests/core/stages*.js # stageDebug.
- jstests/core/startup_log.js # "local" database.
- jstests/core/top.js # top.
diff --git a/jstests/auth/lib/commands_lib.js b/jstests/auth/lib/commands_lib.js
index f3635477545..1ef33169fdb 100644
--- a/jstests/auth/lib/commands_lib.js
+++ b/jstests/auth/lib/commands_lib.js
@@ -5114,42 +5114,6 @@ var authCommandsLib = {
]
},
{
- testname: "repairDatabase",
- command: {repairDatabase: 1},
- skipSharded: true,
- testcases: [
- {
- runOnDb: adminDbName,
- roles:
- {dbAdminAnyDatabase: 1, hostManager: 1, clusterAdmin: 1, root: 1, __system: 1},
- privileges:
- [{resource: {db: adminDbName, collection: ""}, actions: ["repairDatabase"]}]
- },
- {
- runOnDb: firstDbName,
- roles: {
- dbAdmin: 1,
- dbAdminAnyDatabase: 1,
- hostManager: 1,
- clusterAdmin: 1,
- dbOwner: 1,
- root: 1,
- __system: 1
- },
- privileges:
- [{resource: {db: firstDbName, collection: ""}, actions: ["repairDatabase"]}]
- },
- {
- runOnDb: secondDbName,
- roles:
- {dbAdminAnyDatabase: 1, hostManager: 1, clusterAdmin: 1, root: 1, __system: 1},
- privileges: [
- {resource: {db: secondDbName, collection: ""}, actions: ["repairDatabase"]}
- ]
- }
- ]
- },
- {
testname: "replSetFreeze",
command: {replSetFreeze: "x"},
skipSharded: true,
diff --git a/jstests/core/repair_database.js b/jstests/core/repair_database.js
deleted file mode 100644
index ee8b9497cfa..00000000000
--- a/jstests/core/repair_database.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * This tests checks that repair database works and doesn't leave the database in a bad state
- * 1.) Drop "repairDB" database
- * 2.) Ensure repair works with single collection with an extra index. and one doc
- * 3.) Ensure repair works with no docs, same collection/index as above
- * 4.) Ensure repair works with 2 collections, one doc in each
- * 5.) Ensure repair works on the local db (special cases)
- *
- * @tags: [
- * requires_non_retryable_writes,
- *
- * # repairDatabase command is not available on embedded
- * incompatible_with_embedded,
- * ]
- */
-
-// 1. Drop db
-var mydb = db.getSisterDB("repairDB");
-mydb.dropDatabase();
-
-var myColl = mydb.a;
-
-// 2
-var doc = {_id: 1, a: "hello world"};
-myColl.insert(doc);
-myColl.ensureIndex({a: 1});
-assert.commandWorked(mydb.repairDatabase());
-var foundDoc = myColl.findOne();
-
-assert.neq(null, foundDoc);
-assert.eq(1, foundDoc._id);
-
-assert.docEq(doc, myColl.findOne({a: doc.a}));
-assert.docEq(doc, myColl.findOne({_id: 1}));
-
-// 3
-var myColl2 = mydb.b;
-myColl.remove({});
-assert.commandWorked(mydb.repairDatabase());
-
-// 4
-var myColl2 = mydb.b;
-myColl.insert(doc);
-myColl2.insert(doc);
-assert.commandWorked(mydb.repairDatabase());
-assert.docEq(doc, myColl.findOne({a: doc.a}));
-assert.docEq(doc, myColl2.findOne({a: doc.a}));
-
-// 5
-var ldb = db.getSisterDB("local");
-assert.commandWorked(mydb.repairDatabase());
-// Check that inserting to a non-local db still works.
-myColl.insert(doc);
diff --git a/jstests/core/repair_database_input_validation.js b/jstests/core/repair_database_input_validation.js
deleted file mode 100644
index d12b0ced904..00000000000
--- a/jstests/core/repair_database_input_validation.js
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * This tests checks that repair database validates the database exists before executing the
- * repair. Particularly when a command is issued on a different casing than a database that does
- * exist.
- * 1.) Drop "repairDB", "repairdb" and "nonExistantDb" database.
- * 2.) Create "repairDB" by inserting a document.
- * 3.) Repair "repairdb", expect an input validation error.
- * 4.) Repair "nonExistantDb", expect an OK.
- * 5.) Using "listDatabases" verify only "repairDB" exists.
- *
- * @tags: [
- * # repairDatabase command is not available on embedded
- * incompatible_with_embedded,
- * ]
- */
-
-(function() {
- "use strict";
-
- // 1. Drop databases.
- var casing1db = db.getSisterDB("repair_database_input_validation_REPAIRDB");
- casing1db.dropDatabase();
- var casing2db = db.getSisterDB("repair_database_input_validation_repairdb");
- casing2db.dropDatabase();
- var nonExistentDb = db.getSisterDB("repair_database_input_validation_nonExistentDb");
- nonExistentDb.dropDatabase();
-
- // 2. Create "repairDB".
- casing1db.a.insert({_id: 1, a: "hello world"});
-
- var foundDoc = casing1db.a.findOne();
- assert.neq(null, foundDoc);
- assert.eq(1, foundDoc._id);
-
- // 3. Repair "repairdb", verify error.
- var res1 = casing2db.repairDatabase();
- assert.eq(0, res1["ok"]);
- assert.eq(
- true,
- res1["errmsg"].indexOf(
- "Database exists with a different case. Given: `repair_database_input_validation_repairdb` Found: `repair_database_input_validation_REPAIRDB`") >
- -1,
- tojson(res1));
-
- // 4. Repair "nonExistentDb", verify error.
- assert.commandWorked(nonExistentDb.repairDatabase());
-
- // 5. Verify only "repairDB" exists.
- var dbNames = db.getMongo().getDBNames();
- assert.contains(
- "repair_database_input_validation_REPAIRDB", dbNames, "Should contain REPAIRDB");
- assert.eq(false, dbNames.some(function(x) {
- return x == "repair_database_input_validation_repairdb";
- }));
- assert.eq(false, dbNames.some(function(x) {
- return x == "repair_database_input_validation_nonExistentDb";
- }));
-})();
diff --git a/jstests/core/repair_server12955.js b/jstests/core/repair_server12955.js
deleted file mode 100644
index 089454279bc..00000000000
--- a/jstests/core/repair_server12955.js
+++ /dev/null
@@ -1,23 +0,0 @@
-// @tags: [
-// # repairDatabase command is not available on embedded
-// incompatible_with_embedded,
-// ]
-
-mydb = db.getSisterDB("repair_server12955");
-assert.commandWorked(mydb.dropDatabase());
-
-assert.commandWorked(mydb.foo.ensureIndex({a: "text"}));
-assert.writeOK(mydb.foo.insert({a: "hello world"}));
-
-var res = mydb.stats();
-assert.commandWorked(res);
-before = res.dataFileVersion;
-
-assert.commandWorked(mydb.repairDatabase());
-
-res = mydb.stats();
-assert.commandWorked(res);
-after = res.dataFileVersion;
-
-assert.eq(before, after);
-assert.commandWorked(mydb.dropDatabase());
diff --git a/jstests/core/views/views_all_commands.js b/jstests/core/views/views_all_commands.js
index bd707811ce4..cd1db185ba7 100644
--- a/jstests/core/views/views_all_commands.js
+++ b/jstests/core/views/views_all_commands.js
@@ -427,7 +427,7 @@
}
],
repairCursor: {command: {repairCursor: "view"}, expectFailure: true},
- repairDatabase: {command: {repairDatabase: 1}},
+ repairDatabase: {skip: isUnrelated},
replSetAbortPrimaryCatchUp: {skip: isUnrelated},
replSetFreeze: {skip: isUnrelated},
replSetGetConfig: {skip: isUnrelated},
diff --git a/jstests/multiVersion/genericSetFCVUsage/major_version_upgrade.js b/jstests/multiVersion/genericSetFCVUsage/major_version_upgrade.js
index 3d853aed34e..6e54a1f0642 100644
--- a/jstests/multiVersion/genericSetFCVUsage/major_version_upgrade.js
+++ b/jstests/multiVersion/genericSetFCVUsage/major_version_upgrade.js
@@ -71,9 +71,6 @@
// which would fail v:2 validation rules.
assert.commandWorked(testDB.runCommand({compact: collName}));
- // repairDatabase should similarly succeed.
- assert.commandWorked(testDB.runCommand({repairDatabase: 1}));
-
// reIndex will fail because when featureCompatibilityVersion>=3.4, reIndex
// automatically upgrades v=1 indexes to v=2.
assert.commandFailed(testDB[collName].reIndex());
diff --git a/jstests/noPassthrough/index_version_autoupgrade.js b/jstests/noPassthrough/index_version_autoupgrade.js
index f6bbb55eee8..fef289ddca5 100644
--- a/jstests/noPassthrough/index_version_autoupgrade.js
+++ b/jstests/noPassthrough/index_version_autoupgrade.js
@@ -109,13 +109,6 @@
return coll;
}, true);
- // Test that the "repairDatabase" command doesn't upgrade existing indexes to the latest
- // version.
- testIndexVersionAutoUpgrades(function(coll) {
- assert.commandWorked(coll.getDB().runCommand({repairDatabase: 1}));
- return coll;
- }, false);
-
// Test that the "compact" command doesn't upgrade existing indexes to the latest version.
testIndexVersionAutoUpgrades(function(coll) {
var res = coll.getDB().runCommand({compact: coll.getName()});
diff --git a/jstests/noPassthrough/read_majority.js b/jstests/noPassthrough/read_majority.js
index 7c96f3ab330..f9ee8d01607 100644
--- a/jstests/noPassthrough/read_majority.js
+++ b/jstests/noPassthrough/read_majority.js
@@ -181,16 +181,6 @@ load("jstests/libs/analyze_plan.js");
assert.commandWorked(db.adminCommand({"setCommittedSnapshot": newSnapshot}));
assert.eq(getCursorForReadConcernLevel().itcount(), 10);
- // Repair bumps the min snapshot.
- assert.writeOK(t.bump.insert({a: 1})); // Bump timestamp.
- db.repairDatabase();
- assertNoSnapshotAvailableForReadConcernLevel();
- newSnapshot = assert.commandWorked(db.adminCommand("makeSnapshot")).name;
- assertNoSnapshotAvailableForReadConcernLevel();
- assert.commandWorked(db.adminCommand({"setCommittedSnapshot": newSnapshot}));
- assert.eq(getCursorForReadConcernLevel().itcount(), 10);
- assert.eq(getAggCursorForReadConcernLevel().itcount(), 10);
-
// Dropping the collection is visible in the committed snapshot, even though it hasn't been
// marked committed yet. This is allowed by the current specification even though it
// violates strict read-committed semantics since we don't guarantee them on metadata
diff --git a/jstests/noPassthrough/repair2.js b/jstests/noPassthrough/repair2.js
deleted file mode 100644
index 05d73cc762e..00000000000
--- a/jstests/noPassthrough/repair2.js
+++ /dev/null
@@ -1,47 +0,0 @@
-// SERVER-2843 The repair command should not yield.
-
-(function() {
- "use strict";
- const baseName = "jstests_repair2";
-
- const conn = MongoRunner.runMongod();
- assert.neq(null, conn, "mongod failed to start.");
-
- const t = conn.getDB(baseName)[baseName];
- t.drop();
-
- var awaitShell = startParallelShell("db = db.getSiblingDB( '" + baseName + "');" +
- "for( i = 0; i < 10; ++i ) { " +
- "db.repairDatabase();" + "sleep( 5000 );" + " }",
- conn.port);
-
- for (let i = 0; i < 30; ++i) {
- var bulk = t.initializeOrderedBulkOp();
- for (let j = 0; j < 5000; ++j) {
- bulk.insert({_id: j});
- }
-
- for (let j = 0; j < 5000; ++j) {
- bulk.find({_id: j}).remove();
- }
-
- // The bulk operation is expected to succeed, or fail due to interrupt depending on the
- // storage engine.
- try {
- bulk.execute();
- assert.eq(0, t.count());
- } catch (ex) {
- ex.toResult().getWriteErrors().forEach(function(error) {
- assert.eq(error.code, ErrorCodes.QueryPlanKilled, tojson(error));
- assert.eq(error.errmsg, "database closed for repair", tojson(error));
- });
- // The failure may have been a remove, so continuing to the next iteration in the loop
- // would result in a duplicate key on insert.
- break;
- }
- }
-
- awaitShell();
-
- MongoRunner.stopMongod(conn);
-})();
diff --git a/jstests/noPassthroughWithMongod/repair_unsupported_options.js b/jstests/noPassthroughWithMongod/repair_unsupported_options.js
deleted file mode 100644
index da73875e753..00000000000
--- a/jstests/noPassthroughWithMongod/repair_unsupported_options.js
+++ /dev/null
@@ -1,10 +0,0 @@
-// SERVER-35112: Test that specifying removed MMAPv1 specific options gives correct error.
-(function() {
- 'use strict';
- db.repair_unsupported_options.drop();
- assert.commandWorked(db.repair_unsupported_options.insert({})); // Ensure database exists.
- let badValue = (cmd) => assert.commandFailedWithCode(db.runCommand(cmd), ErrorCodes.BadValue);
- badValue({repairDatabase: 1, preserveClonedFilesOnFailure: 1});
- badValue({repairDatabase: 1, backupOriginalFiles: 1});
- assert.commandWorked(db.runCommand({repairDatabase: 1, someRandomUnknownOption: 1}));
-})();
diff --git a/jstests/replsets/drop_databases_two_phase.js b/jstests/replsets/drop_databases_two_phase.js
index d6c1ea454f1..e4f4dac378c 100644
--- a/jstests/replsets/drop_databases_two_phase.js
+++ b/jstests/replsets/drop_databases_two_phase.js
@@ -119,10 +119,6 @@
ErrorCodes.DatabaseDropPending,
'collection creation should fail while we are in the process of dropping the database');
assert.commandFailedWithCode(
- dbToDrop.repairDatabase(),
- ErrorCodes.DatabaseDropPending,
- 'repairDatabase should fail while we are in the process of dropping the database');
- assert.commandFailedWithCode(
dbToDrop.adminCommand('restartCatalog'),
ErrorCodes.DatabaseDropPending,
'restartCatalog should fail if any databases are marked drop-pending');
diff --git a/jstests/replsets/read_committed_with_catalog_changes.js b/jstests/replsets/read_committed_with_catalog_changes.js
index b60fda763f2..172463bdf99 100644
--- a/jstests/replsets/read_committed_with_catalog_changes.js
+++ b/jstests/replsets/read_committed_with_catalog_changes.js
@@ -165,17 +165,6 @@ load("jstests/replsets/rslib.js"); // For startSetIfSupportsReadMajority.
},
// Remaining cases are local-only operations.
- repairDatabase: {
- prepare: function(db) {
- assert.writeOK(db.coll.insert({_id: 1}));
- },
- performOp: function(db) {
- assert.commandWorked(db.repairDatabase());
- },
- blockedCollections: ['coll'],
- unblockedCollections: ['otherDoesNotExist'],
- localOnly: true,
- },
reIndex: {
prepare: function(db) {
assert.writeOK(db.other.insert({_id: 1}));
diff --git a/jstests/sharding/safe_secondary_reads_drop_recreate.js b/jstests/sharding/safe_secondary_reads_drop_recreate.js
index 6a4ea88cac6..1aaa2dbcb61 100644
--- a/jstests/sharding/safe_secondary_reads_drop_recreate.js
+++ b/jstests/sharding/safe_secondary_reads_drop_recreate.js
@@ -248,7 +248,6 @@
removeShardFromZone: {skip: "primary only"},
renameCollection: {skip: "primary only"},
repairCursor: {skip: "does not return user data"},
- repairDatabase: {skip: "does not return user data"},
replSetAbortPrimaryCatchUp: {skip: "does not return user data"},
replSetFreeze: {skip: "does not return user data"},
replSetGetConfig: {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 1ae049a44d2..fc702d40491 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
@@ -283,7 +283,6 @@
removeShardFromZone: {skip: "primary only"},
renameCollection: {skip: "primary only"},
repairCursor: {skip: "does not return user data"},
- repairDatabase: {skip: "does not return user data"},
replSetAbortPrimaryCatchUp: {skip: "does not return user data"},
replSetFreeze: {skip: "does not return user data"},
replSetGetConfig: {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 a3adedfd3ea..d449250cb36 100644
--- a/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
+++ b/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
@@ -253,7 +253,6 @@
removeShardFromZone: {skip: "primary only"},
renameCollection: {skip: "primary only"},
repairCursor: {skip: "does not return user data"},
- repairDatabase: {skip: "does not return user data"},
replSetAbortPrimaryCatchUp: {skip: "does not return user data"},
replSetFreeze: {skip: "does not return user data"},
replSetGetConfig: {skip: "does not return user data"},
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)
diff --git a/src/mongo/shell/db.js b/src/mongo/shell/db.js
index 0304410caef..692205ff78e 100644
--- a/src/mongo/shell/db.js
+++ b/src/mongo/shell/db.js
@@ -583,15 +583,6 @@ var DB;
});
};
- /**
- Repair database.
-
- * @return Object returned has member ok set to true if operation succeeds, false otherwise.
- */
- DB.prototype.repairDatabase = function() {
- return this._dbCommand({repairDatabase: 1});
- };
-
DB.prototype.help = function() {
print("DB methods:");
print(
@@ -640,7 +631,6 @@ var DB;
print("\tdb.printShardingStatus()");
print("\tdb.printSlaveReplicationInfo()");
print("\tdb.dropUser(username)");
- print("\tdb.repairDatabase()");
print("\tdb.resetError()");
print(
"\tdb.runCommand(cmdObj) run a database command. if cmdObj is a string, turns it into {cmdObj: 1}");