summaryrefslogtreecommitdiff
path: root/src/mongo/db/dbcommands.cpp
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2015-06-05 17:44:36 -0400
committerEric Milkie <milkie@10gen.com>2015-06-05 17:48:23 -0400
commitb1d6f667a771fb5768978e89ae32cc862b74904f (patch)
treed3c08f1823f83134e448e738675076e59d7f71f0 /src/mongo/db/dbcommands.cpp
parentbfdf548bc4c882ab944e0cf2f1e6015752fc05c2 (diff)
downloadmongo-b1d6f667a771fb5768978e89ae32cc862b74904f.tar.gz
SERVER-17923 prohibit database/collection actions when bg index is running
Diffstat (limited to 'src/mongo/db/dbcommands.cpp')
-rw-r--r--src/mongo/db/dbcommands.cpp66
1 files changed, 3 insertions, 63 deletions
diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp
index a9cb7c6e88b..1c7c280f9c7 100644
--- a/src/mongo/db/dbcommands.cpp
+++ b/src/mongo/db/dbcommands.cpp
@@ -146,30 +146,6 @@ namespace mongo {
virtual bool isWriteCommandForConfigServer() const { return true; }
- virtual std::vector<BSONObj> stopIndexBuilds(OperationContext* opCtx,
- Database* db,
- const BSONObj& cmdObj) {
- invariant(db);
- std::list<std::string> collections;
- db->getDatabaseCatalogEntry()->getCollectionNamespaces(&collections);
-
- std::vector<BSONObj> allKilledIndexes;
- for (std::list<std::string>::iterator it = collections.begin();
- it != collections.end();
- ++it) {
- std::string ns = *it;
-
- IndexCatalog::IndexKillCriteria criteria;
- criteria.ns = ns;
- std::vector<BSONObj> killedIndexes =
- IndexBuilder::killMatchingIndexBuilds(db->getCollection(ns), criteria);
- allKilledIndexes.insert(allKilledIndexes.end(),
- killedIndexes.begin(),
- killedIndexes.end());
- }
- return allKilledIndexes;
- }
-
CmdDropDatabase() : Command("dropDatabase") {}
bool run(OperationContext* txn, const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
@@ -210,7 +186,7 @@ namespace mongo {
log() << "dropDatabase " << dbname << " starting" << endl;
- stopIndexBuilds(txn, db, cmdObj);
+ BackgroundOperation::assertNoBgOpInProgForDb(dbname);
dropDatabase(txn, db);
log() << "dropDatabase " << dbname << " finished";
@@ -254,30 +230,6 @@ namespace mongo {
}
- virtual std::vector<BSONObj> stopIndexBuilds(OperationContext* opCtx,
- Database* db,
- const BSONObj& cmdObj) {
- invariant(db);
- std::list<std::string> collections;
- db->getDatabaseCatalogEntry()->getCollectionNamespaces(&collections);
-
- std::vector<BSONObj> allKilledIndexes;
- for (std::list<std::string>::iterator it = collections.begin();
- it != collections.end();
- ++it) {
- std::string ns = *it;
-
- IndexCatalog::IndexKillCriteria criteria;
- criteria.ns = ns;
- std::vector<BSONObj> killedIndexes =
- IndexBuilder::killMatchingIndexBuilds(db->getCollection(ns), criteria);
- allKilledIndexes.insert(allKilledIndexes.end(),
- killedIndexes.begin(),
- killedIndexes.end());
- }
- return allKilledIndexes;
- }
-
bool run(OperationContext* txn, const string& dbname , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
BSONElement e = cmdObj.firstElement();
if ( e.numberInt() != 1 ) {
@@ -291,7 +243,7 @@ namespace mongo {
Client::Context context(txn, dbname );
log() << "repairDatabase " << dbname;
- std::vector<BSONObj> indexesInProg = stopIndexBuilds(txn, context.db(), cmdObj);
+ BackgroundOperation::assertNoBgOpInProgForDb(dbname);
e = cmdObj.getField( "preserveClonedFilesOnFailure" );
bool preserveClonedFilesOnFailure = e.isBoolean() && e.boolean();
@@ -302,8 +254,6 @@ namespace mongo {
Status status = repairDatabase(txn, engine, dbname, preserveClonedFilesOnFailure,
backupOriginalFiles );
- IndexBuilder::restoreIndexes(txn, indexesInProg);
-
// Open database before returning
dbHolder().openDb(txn, dbname);
return appendCommandStatus( result, status );
@@ -465,16 +415,6 @@ namespace mongo {
virtual bool isWriteCommandForConfigServer() const { return true; }
- virtual std::vector<BSONObj> stopIndexBuilds(OperationContext* opCtx,
- Database* db,
- const BSONObj& cmdObj) {
- const std::string nsToDrop = parseNsCollectionRequired(db->name(), cmdObj);
-
- IndexCatalog::IndexKillCriteria criteria;
- criteria.ns = nsToDrop;
- return IndexBuilder::killMatchingIndexBuilds(db->getCollection(nsToDrop), criteria);
- }
-
virtual bool run(OperationContext* txn, const string& dbname , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
const std::string nsToDrop = parseNsCollectionRequired(dbname, cmdObj);
@@ -515,7 +455,7 @@ namespace mongo {
int numIndexes = coll->getIndexCatalog()->numIndexesTotal( txn );
- stopIndexBuilds(txn, db, cmdObj);
+ BackgroundOperation::assertNoBgOpInProgForNs(nsToDrop);
result.append( "ns", nsToDrop );
result.append( "nIndexesWas", numIndexes );