summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/catalog/capped_utils.cpp28
-rw-r--r--src/mongo/db/catalog/drop_collection.cpp14
-rw-r--r--src/mongo/db/catalog/drop_database.cpp27
-rw-r--r--src/mongo/db/catalog/drop_indexes.cpp34
-rw-r--r--src/mongo/db/catalog/index_catalog.cpp44
-rw-r--r--src/mongo/db/catalog/index_catalog.h31
-rw-r--r--src/mongo/db/catalog/index_create.cpp14
-rw-r--r--src/mongo/db/catalog/index_create.h16
-rw-r--r--src/mongo/db/catalog/rename_collection.cpp32
-rw-r--r--src/mongo/db/commands/collection_to_capped.cpp12
-rw-r--r--src/mongo/db/commands/compact.cpp14
-rw-r--r--src/mongo/db/commands/drop_indexes.cpp12
-rw-r--r--src/mongo/db/commands/rename_collection.cpp24
-rw-r--r--src/mongo/db/dbcommands.cpp30
-rw-r--r--src/mongo/db/index_builder.cpp21
-rw-r--r--src/mongo/db/index_builder.h16
-rw-r--r--src/mongo/db/repl/oplog.cpp2
17 files changed, 13 insertions, 358 deletions
diff --git a/src/mongo/db/catalog/capped_utils.cpp b/src/mongo/db/catalog/capped_utils.cpp
index b90edb2c432..eb0265b0877 100644
--- a/src/mongo/db/catalog/capped_utils.cpp
+++ b/src/mongo/db/catalog/capped_utils.cpp
@@ -49,29 +49,6 @@
#include "mongo/util/scopeguard.h"
namespace mongo {
-namespace {
- std::vector<BSONObj> stopIndexBuildsEmptyCapped(OperationContext* opCtx,
- Database* db,
- const NamespaceString& ns) {
- IndexCatalog::IndexKillCriteria criteria;
- criteria.ns = ns;
- return IndexBuilder::killMatchingIndexBuilds(db->getCollection(ns), criteria);
- }
-
- std::vector<BSONObj> stopIndexBuildsConvertToCapped(OperationContext* opCtx,
- Database* db,
- const NamespaceString& ns) {
- IndexCatalog::IndexKillCriteria criteria;
- criteria.ns = ns;
- Collection* coll = db->getCollection(ns);
- if (coll) {
- return IndexBuilder::killMatchingIndexBuilds(coll, criteria);
- }
- return std::vector<BSONObj>();
- }
-
-} // namespace
-
Status emptyCapped(OperationContext* txn,
const NamespaceString& collectionName) {
ScopedTransaction scopedXact(txn, MODE_IX);
@@ -93,7 +70,7 @@ namespace {
Collection* collection = db->getCollection(collectionName);
massert(28584, "no such collection", collection);
- std::vector<BSONObj> indexes = stopIndexBuildsEmptyCapped(txn, db, collectionName);
+ BackgroundOperation::assertNoBgOpInProgForNs(collectionName.ns());
WriteUnitOfWork wuow(txn);
@@ -102,8 +79,6 @@ namespace {
return status;
}
- IndexBuilder::restoreIndexes(txn, indexes);
-
getGlobalServiceContext()->getOpObserver()->onEmptyCapped(txn, collection->ns());
wuow.commit();
@@ -257,7 +232,6 @@ namespace {
str::stream() << "database " << dbname << " not found");
}
- stopIndexBuildsConvertToCapped(txn, db, collectionName);
BackgroundOperation::assertNoBgOpInProgForDb(dbname);
std::string shortTmpName = str::stream() << "tmp.convertToCapped." << shortSource;
diff --git a/src/mongo/db/catalog/drop_collection.cpp b/src/mongo/db/catalog/drop_collection.cpp
index 3fb248ecb79..d1d5fa5c986 100644
--- a/src/mongo/db/catalog/drop_collection.cpp
+++ b/src/mongo/db/catalog/drop_collection.cpp
@@ -32,6 +32,7 @@
#include "mongo/db/catalog/drop_collection.h"
+#include "mongo/db/background.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/index_catalog.h"
@@ -47,17 +48,6 @@
#include "mongo/util/log.h"
namespace mongo {
-namespace {
- std::vector<BSONObj> stopIndexBuilds(OperationContext* opCtx,
- Database* db,
- const NamespaceString& collectionName) {
- IndexCatalog::IndexKillCriteria criteria;
- criteria.ns = collectionName;
- return IndexBuilder::killMatchingIndexBuilds(db->getCollection(collectionName),
- criteria);
- }
-
-} // namespace
Status dropCollection(OperationContext* txn,
const NamespaceString& collectionName,
BSONObjBuilder& result) {
@@ -91,7 +81,7 @@ namespace {
int numIndexes = coll->getIndexCatalog()->numIndexesTotal(txn);
- stopIndexBuilds(txn, db, collectionName);
+ BackgroundOperation::assertNoBgOpInProgForNs(collectionName.ns());
WriteUnitOfWork wunit(txn);
Status s = db->dropCollection(txn, collectionName.ns());
diff --git a/src/mongo/db/catalog/drop_database.cpp b/src/mongo/db/catalog/drop_database.cpp
index 655305d216e..ab6f3131932 100644
--- a/src/mongo/db/catalog/drop_database.cpp
+++ b/src/mongo/db/catalog/drop_database.cpp
@@ -32,6 +32,7 @@
#include "mongo/db/catalog/drop_database.h"
+#include "mongo/db/background.h"
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/database_catalog_entry.h"
#include "mongo/db/catalog/index_catalog.h"
@@ -47,30 +48,6 @@
#include "mongo/util/log.h"
namespace mongo {
-namespace {
- std::vector<BSONObj> stopIndexBuilds(OperationContext* opCtx, Database* db) {
- 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;
- }
-} // namespace
-
Status dropDatabase(OperationContext* txn, const std::string& dbName) {
MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
ScopedTransaction transaction(txn, MODE_X);
@@ -93,7 +70,7 @@ namespace {
log() << "dropDatabase " << dbName << " starting";
- stopIndexBuilds(txn, db);
+ BackgroundOperation::assertNoBgOpInProgForDb(dbName);
mongo::dropDatabase(txn, db);
log() << "dropDatabase " << dbName << " finished";
diff --git a/src/mongo/db/catalog/drop_indexes.cpp b/src/mongo/db/catalog/drop_indexes.cpp
index 0ac1c2dae13..aeedac83c3f 100644
--- a/src/mongo/db/catalog/drop_indexes.cpp
+++ b/src/mongo/db/catalog/drop_indexes.cpp
@@ -32,6 +32,7 @@
#include "mongo/db/catalog/drop_indexes.h"
+#include "mongo/db/background.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/index_catalog.h"
@@ -47,37 +48,6 @@
namespace mongo {
namespace {
- std::vector<BSONObj> stopIndexBuilds(OperationContext* opCtx,
- Database* db,
- const std::string& toDeleteNs,
- const BSONObj& cmdObj) {
- Collection* collection = db->getCollection(toDeleteNs);
- IndexCatalog::IndexKillCriteria criteria;
-
- // Get index name to drop
- BSONElement toDrop = cmdObj.getField("index");
-
- if (toDrop.type() == String) {
- // Kill all in-progress indexes
- if (strcmp("*", toDrop.valuestr()) == 0) {
- criteria.ns = toDeleteNs;
- return IndexBuilder::killMatchingIndexBuilds(collection, criteria);
- }
- // Kill an in-progress index by name
- else {
- criteria.name = toDrop.valuestr();
- return IndexBuilder::killMatchingIndexBuilds(collection, criteria);
- }
- }
- // Kill an in-progress index build by index key
- else if (toDrop.type() == Object) {
- criteria.key = toDrop.Obj();
- return IndexBuilder::killMatchingIndexBuilds(collection, criteria);
- }
-
- return std::vector<BSONObj>();
- }
-
Status wrappedRun(OperationContext* txn,
const StringData& dbname,
const std::string& toDeleteNs,
@@ -95,7 +65,7 @@ namespace {
}
OldClientContext ctx(txn, toDeleteNs);
- stopIndexBuilds(txn, db, toDeleteNs, jsobj);
+ BackgroundOperation::assertNoBgOpInProgForNs(toDeleteNs);
IndexCatalog* indexCatalog = collection->getIndexCatalog();
anObjBuilder->appendNumber("nIndexesWas", indexCatalog->numIndexesTotal(txn));
diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp
index 46c568c9617..cf6c7a90e67 100644
--- a/src/mongo/db/catalog/index_catalog.cpp
+++ b/src/mongo/db/catalog/index_catalog.cpp
@@ -319,16 +319,6 @@ namespace {
return StatusWith<BSONObj>( fixed );
}
- void IndexCatalog::registerIndexBuild(IndexDescriptor* descriptor, unsigned int opNum) {
- _inProgressIndexes[descriptor] = opNum;
- }
-
- void IndexCatalog::unregisterIndexBuild(IndexDescriptor* descriptor) {
- InProgressIndexesMap::iterator it = _inProgressIndexes.find(descriptor);
- invariant(it != _inProgressIndexes.end());
- _inProgressIndexes.erase(it);
- }
-
Status IndexCatalog::createIndexOnEmptyCollection(OperationContext* txn, BSONObj spec) {
invariant(txn->lockState()->isCollectionLockedForMode(_collection->ns().toString(),
MODE_X));
@@ -1286,38 +1276,4 @@ namespace {
return b.obj();
}
- std::vector<BSONObj>
- IndexCatalog::killMatchingIndexBuilds(const IndexCatalog::IndexKillCriteria& criteria) {
- std::vector<BSONObj> indexes;
- for (InProgressIndexesMap::iterator it = _inProgressIndexes.begin();
- it != _inProgressIndexes.end();
- it++) {
- // check criteria
- IndexDescriptor* desc = it->first;
- unsigned int opNum = it->second;
- if (!criteria.ns.empty() && (desc->parentNS() != criteria.ns)) {
- continue;
- }
- if (!criteria.name.empty() && (desc->indexName() != criteria.name)) {
- continue;
- }
- if (!criteria.key.isEmpty() && (desc->keyPattern() != criteria.key)) {
- continue;
- }
- indexes.push_back(desc->keyPattern().getOwned());
- log() << "halting index build: " << desc->keyPattern();
- // Note that we can only be here if the background index build in question is
- // yielding. The bg index code is set up specially to check for interrupt
- // immediately after it recovers from yield, such that no further work is done
- // on the index build. Thus this thread does not have to synchronize with the
- // bg index operation; we can just assume that it is safe to proceed.
- getGlobalServiceContext()->killOperation(opNum);
- }
-
- if (indexes.size() > 0) {
- log() << "halted " << indexes.size() << " index build(s)" << endl;
- }
-
- return indexes;
- }
}
diff --git a/src/mongo/db/catalog/index_catalog.h b/src/mongo/db/catalog/index_catalog.h
index 9bc34690891..6b746fe6fd5 100644
--- a/src/mongo/db/catalog/index_catalog.h
+++ b/src/mongo/db/catalog/index_catalog.h
@@ -212,32 +212,6 @@ namespace mongo {
BSONObj key;
};
- /**
- * Registers an index build in an internal tracking map, for use with
- * killMatchingIndexBuilds(). The opNum and descriptor provided must remain active
- * for as long as the entry exists in the map. The opNum provided must correspond to
- * an operation building only one index, in the background.
- * This function is intended for replication to use for tracking and managing background
- * index builds. It is expected that the caller has already taken steps to serialize
- * calls to this function.
- */
- void registerIndexBuild(IndexDescriptor* descriptor, unsigned int opNum);
-
- /**
- * Removes an index build from the map, upon completion or termination of the index build.
- * This function is intended for replication to use for tracking and managing background
- * index builds. It is expected that the caller has already taken steps to serialize
- * calls to this function.
- */
- void unregisterIndexBuild(IndexDescriptor* descriptor);
-
- /**
- * Given some criteria, searches through all in-progress index builds
- * and kills ones that match. (namespace, index name, and/or index key spec)
- * Returns the list of index specs that were killed, for use in restarting them later.
- */
- std::vector<BSONObj> killMatchingIndexBuilds(const IndexKillCriteria& criteria);
-
// ---- modify single index
bool isMultikey( OperationContext* txn, const IndexDescriptor* idex );
@@ -314,8 +288,6 @@ namespace mongo {
static BSONObj fixIndexKey( const BSONObj& key );
private:
- typedef unordered_map<IndexDescriptor*, unsigned int> InProgressIndexesMap;
-
static const BSONObj _idObj; // { _id : 1 }
bool _shouldOverridePlugin( OperationContext* txn, const BSONObj& keyPattern ) const;
@@ -380,9 +352,6 @@ namespace mongo {
// Certain operations are prohibited until someone fixes.
// Retrieve by calling getAndClearUnfinishedIndexes().
std::vector<BSONObj> _unfinishedIndexes;
-
- // Track in-progress index builds, in order to find and stop them when necessary.
- InProgressIndexesMap _inProgressIndexes;
};
}
diff --git a/src/mongo/db/catalog/index_create.cpp b/src/mongo/db/catalog/index_create.cpp
index 3eee9cae3b6..01dfb1037e4 100644
--- a/src/mongo/db/catalog/index_create.cpp
+++ b/src/mongo/db/catalog/index_create.cpp
@@ -223,20 +223,6 @@ namespace mongo {
return Status::OK();
}
- IndexDescriptor* MultiIndexBlock::registerIndexBuild() {
- // Register background index build so that it can be found and killed when necessary
- invariant(_collection);
- invariant(_indexes.size() == 1);
- invariant(_buildInBackground);
- IndexDescriptor* descriptor = _indexes[0].block->getEntry()->descriptor();
- _collection->getIndexCatalog()->registerIndexBuild(descriptor, _txn->getOpID());
- return descriptor;
- }
-
- void MultiIndexBlock::unregisterIndexBuild(IndexDescriptor* descriptor) {
- _collection->getIndexCatalog()->unregisterIndexBuild(descriptor);
- }
-
Status MultiIndexBlock::insertAllDocumentsInCollection(std::set<RecordId>* dupsOut) {
const char* curopMessage = _buildInBackground ? "Index Build (background)" : "Index Build";
ProgressMeterHolder progress(*_txn->setMessage(curopMessage,
diff --git a/src/mongo/db/catalog/index_create.h b/src/mongo/db/catalog/index_create.h
index 9c0b11ed02a..f4be38710cd 100644
--- a/src/mongo/db/catalog/index_create.h
+++ b/src/mongo/db/catalog/index_create.h
@@ -111,22 +111,6 @@ namespace mongo {
}
/**
- * Manages in-progress background index builds.
- * Call registerIndexBuild() after calling init() to record this build in the catalog's
- * in-progress map.
- * The build must be a background build and it must be a single index build (the size of
- * _indexes must be 1).
- * registerIndexBuild() returns the descriptor for the index build. You must subsequently
- * call unregisterIndexBuild() with that same descriptor before this MultiIndexBlock goes
- * out of scope.
- * These functions are only intended to be used by the replication system. No internal
- * concurrency control is performed; it is expected that the code has already taken steps
- * to ensure calls to these functions are serialized, for a particular IndexCatalog.
- */
- IndexDescriptor* registerIndexBuild();
- void unregisterIndexBuild(IndexDescriptor* descriptor);
-
- /**
* Inserts all documents in the Collection into the indexes and logs with timing info.
*
* This is a simplified replacement for insert and doneInserting. Do not call this if you
diff --git a/src/mongo/db/catalog/rename_collection.cpp b/src/mongo/db/catalog/rename_collection.cpp
index ecf7b5e2515..361500933f5 100644
--- a/src/mongo/db/catalog/rename_collection.cpp
+++ b/src/mongo/db/catalog/rename_collection.cpp
@@ -32,6 +32,7 @@
#include "mongo/db/catalog/rename_collection.h"
+#include "mongo/db/background.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/collection_catalog_entry.h"
#include "mongo/db/catalog/database.h"
@@ -57,31 +58,6 @@ namespace {
wunit.commit();
}
}
-
- // renameCollection's
- std::vector<BSONObj> stopIndexBuilds(OperationContext* opCtx,
- Database* db,
- const NamespaceString& source,
- const NamespaceString& target) {
-
- IndexCatalog::IndexKillCriteria criteria;
- criteria.ns = source;
- std::vector<BSONObj> prelim =
- IndexBuilder::killMatchingIndexBuilds(db->getCollection(source), criteria);
-
- std::vector<BSONObj> indexes;
-
- for (int i = 0; i < static_cast<int>(prelim.size()); i++) {
- // Change the ns
- BSONObj stripped = prelim[i].removeField("ns");
- BSONObjBuilder builder;
- builder.appendElements(stripped);
- builder.append("ns", target);
- indexes.push_back(builder.obj());
- }
-
- return indexes;
- }
} // namespace
Status renameCollection(OperationContext* txn,
@@ -136,9 +112,7 @@ namespace {
}
}
- const std::vector<BSONObj> indexesInProg = stopIndexBuilds(txn, sourceDB, source, target);
- // Dismissed on success
- ScopeGuard indexBuildRestorer = MakeGuard(IndexBuilder::restoreIndexes, txn, indexesInProg);
+ BackgroundOperation::assertNoBgOpInProgForNs(source.ns());
Database* const targetDB = dbHolder().openDb(txn, target.db());
@@ -175,7 +149,6 @@ namespace {
stayTemp);
wunit.commit();
- indexBuildRestorer.Dismiss();
return Status::OK();
}
@@ -278,7 +251,6 @@ namespace {
wunit.commit();
}
- indexBuildRestorer.Dismiss();
targetCollectionDropper.Dismiss();
return Status::OK();
}
diff --git a/src/mongo/db/commands/collection_to_capped.cpp b/src/mongo/db/commands/collection_to_capped.cpp
index 97e4637d296..772c1682e37 100644
--- a/src/mongo/db/commands/collection_to_capped.cpp
+++ b/src/mongo/db/commands/collection_to_capped.cpp
@@ -136,18 +136,6 @@ namespace mongo {
out->push_back(Privilege(parseResourcePattern(dbname, cmdObj), actions));
}
- std::vector<BSONObj> stopIndexBuilds(OperationContext* opCtx,
- Database* db,
- const NamespaceString& ns) {
- IndexCatalog::IndexKillCriteria criteria;
- criteria.ns = ns;
- Collection* coll = db->getCollection(ns);
- if (coll) {
- return IndexBuilder::killMatchingIndexBuilds(coll, criteria);
- }
- return std::vector<BSONObj>();
- }
-
bool run(OperationContext* txn,
const string& dbname,
BSONObj& jsobj,
diff --git a/src/mongo/db/commands/compact.cpp b/src/mongo/db/commands/compact.cpp
index c0986823389..e0c935a3f19 100644
--- a/src/mongo/db/commands/compact.cpp
+++ b/src/mongo/db/commands/compact.cpp
@@ -77,16 +77,6 @@ namespace mongo {
}
CompactCmd() : Command("compact") { }
- virtual std::vector<BSONObj> stopIndexBuilds(OperationContext* opCtx,
- Database* db,
- const BSONObj& cmdObj) {
- const std::string ns = parseNsCollectionRequired(db->name(), cmdObj);
-
- IndexCatalog::IndexKillCriteria criteria;
- criteria.ns = ns;
- return IndexBuilder::killMatchingIndexBuilds(db->getCollection(ns), criteria);
- }
-
virtual bool run(OperationContext* txn,
const string& db,
BSONObj& cmdObj,
@@ -169,8 +159,6 @@ namespace mongo {
log() << "compact " << ns << " begin, options: " << compactOptions.toString();
- std::vector<BSONObj> indexesInProg = stopIndexBuilds(txn, collDB, cmdObj);
-
StatusWith<CompactStats> status = collection->compact( txn, &compactOptions );
if ( !status.isOK() )
return appendCommandStatus( result, status.getStatus() );
@@ -180,8 +168,6 @@ namespace mongo {
log() << "compact " << ns << " end";
- IndexBuilder::restoreIndexes(txn, indexesInProg);
-
return true;
}
};
diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp
index d4558145bce..52dfba38bf2 100644
--- a/src/mongo/db/commands/drop_indexes.cpp
+++ b/src/mongo/db/commands/drop_indexes.cpp
@@ -115,15 +115,6 @@ namespace mongo {
}
CmdReIndex() : Command("reIndex") { }
- virtual std::vector<BSONObj> stopIndexBuilds(OperationContext* opCtx,
- Database* db,
- const BSONObj& cmdObj) {
- const std::string ns = parseNsCollectionRequired(db->name(), cmdObj);
- IndexCatalog::IndexKillCriteria criteria;
- criteria.ns = ns;
- return IndexBuilder::killMatchingIndexBuilds(db->getCollection(ns), criteria);
- }
-
bool run(OperationContext* txn,
const string& dbname,
BSONObj& jsobj,
@@ -149,8 +140,6 @@ namespace mongo {
BackgroundOperation::assertNoBgOpInProgForNs( toDeleteNs );
- std::vector<BSONObj> indexesInProg = stopIndexBuilds(txn, ctx.db(), jsobj);
-
vector<BSONObj> all;
{
vector<string> indexNames;
@@ -203,7 +192,6 @@ namespace mongo {
result.append( "nIndexes", (int)all.size() );
result.append( "indexes", all );
- IndexBuilder::restoreIndexes(txn, indexesInProg);
return true;
}
} cmdReIndex;
diff --git a/src/mongo/db/commands/rename_collection.cpp b/src/mongo/db/commands/rename_collection.cpp
index 91d7ac3254f..5479ee92a40 100644
--- a/src/mongo/db/commands/rename_collection.cpp
+++ b/src/mongo/db/commands/rename_collection.cpp
@@ -75,30 +75,6 @@ namespace mongo {
help << " example: { renameCollection: foo.a, to: bar.b }";
}
- std::vector<BSONObj> stopIndexBuilds(OperationContext* opCtx,
- Database* db,
- const NamespaceString& source,
- const NamespaceString& target) {
-
- IndexCatalog::IndexKillCriteria criteria;
- criteria.ns = source;
- std::vector<BSONObj> prelim =
- IndexBuilder::killMatchingIndexBuilds(db->getCollection(source), criteria);
-
- std::vector<BSONObj> indexes;
-
- for (int i = 0; i < static_cast<int>(prelim.size()); i++) {
- // Change the ns
- BSONObj stripped = prelim[i].removeField("ns");
- BSONObjBuilder builder;
- builder.appendElements(stripped);
- builder.append("ns", target);
- indexes.push_back(builder.obj());
- }
-
- return indexes;
- }
-
static void dropCollection(OperationContext* txn, Database* db, StringData collName) {
WriteUnitOfWork wunit(txn);
if (db->dropCollection(txn, collName).isOK()) {
diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp
index a8fa185b86f..828bfa03215 100644
--- a/src/mongo/db/dbcommands.cpp
+++ b/src/mongo/db/dbcommands.cpp
@@ -240,30 +240,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,
@@ -279,10 +255,10 @@ namespace mongo {
// TODO: SERVER-4328 Don't lock globally
ScopedTransaction transaction(txn, MODE_X);
Lock::GlobalWrite lk(txn->lockState());
- OldClientContext context(txn, dbname );
+ OldClientContext 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();
@@ -296,8 +272,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 );
diff --git a/src/mongo/db/index_builder.cpp b/src/mongo/db/index_builder.cpp
index 45620ee0544..6d205c45da9 100644
--- a/src/mongo/db/index_builder.cpp
+++ b/src/mongo/db/index_builder.cpp
@@ -155,7 +155,6 @@ namespace {
indexer.allowBackgroundBuilding();
- IndexDescriptor* descriptor(NULL);
try {
status = indexer.init(_index);
if ( status.code() == ErrorCodes::IndexAlreadyExists ) {
@@ -168,7 +167,6 @@ namespace {
if (status.isOK()) {
if (allowBackgroundBuilding) {
- descriptor = indexer.registerIndexBuild();
if (!haveSetBgIndexStarting) {
_setBgIndexStarting();
haveSetBgIndexStarting = true;
@@ -199,7 +197,6 @@ namespace {
Database* reloadDb = dbHolder().get(txn, ns.db());
fassert(28553, reloadDb);
fassert(28554, reloadDb->getCollection(ns.ns()));
- indexer.unregisterIndexBuild(descriptor);
}
if (status.code() == ErrorCodes::InterruptedAtShutdown) {
@@ -219,22 +216,4 @@ namespace {
txn->recoveryUnit()->abandonSnapshot();
}
}
-
- std::vector<BSONObj>
- IndexBuilder::killMatchingIndexBuilds(Collection* collection,
- const IndexCatalog::IndexKillCriteria& criteria) {
- invariant(collection);
- return collection->getIndexCatalog()->killMatchingIndexBuilds(criteria);
- }
-
- void IndexBuilder::restoreIndexes(OperationContext* txn, const std::vector<BSONObj>& indexes) {
- log() << "restarting " << indexes.size() << " background index build(s)" << endl;
- for (int i = 0; i < static_cast<int>(indexes.size()); i++) {
- IndexBuilder* indexBuilder = new IndexBuilder(indexes[i]);
- // This looks like a memory leak, but indexBuilder deletes itself when it finishes
- indexBuilder->go();
- Lock::TempRelease release(txn->lockState());
- IndexBuilder::waitForBgIndexStarting();
- }
- }
}
diff --git a/src/mongo/db/index_builder.h b/src/mongo/db/index_builder.h
index b32c6b5d988..dabfe92bae2 100644
--- a/src/mongo/db/index_builder.h
+++ b/src/mongo/db/index_builder.h
@@ -75,22 +75,6 @@ namespace mongo {
Status buildInForeground(OperationContext* txn, Database* db) const;
/**
- * Kill all in-progress indexes matching criteria, if non-empty:
- * index ns, index name, and/or index key spec.
- * Returns a vector of the indexes that were killed.
- */
- static std::vector<BSONObj>
- killMatchingIndexBuilds(Collection* collection,
- const IndexCatalog::IndexKillCriteria& criteria);
-
- /**
- * Retry all index builds in the list. Builds each index in a separate thread. If ns does
- * not match the ns field in the indexes list, the BSONObj's ns field is changed before the
- * index is built (to handle rename).
- */
- static void restoreIndexes(OperationContext* txn, const std::vector<BSONObj>& indexes);
-
- /**
* Waits for a background index build to register itself. This function must be called
* after starting a background index build via a BackgroundJob and before starting a
* subsequent one.
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index eed93e1561a..4248a1026f7 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -828,6 +828,7 @@ namespace {
Lock::TempRelease release(txn->lockState());
BackgroundOperation::awaitNoBgOpInProgForDb(nsToDatabaseSubstring(ns));
+ txn->recoveryUnit()->abandonSnapshot();
break;
}
case ErrorCodes::BackgroundOperationInProgressForNamespace: {
@@ -836,6 +837,7 @@ namespace {
Command* cmd = Command::findCommand(o.firstElement().fieldName());
invariant(cmd);
BackgroundOperation::awaitNoBgOpInProgForNs(cmd->parseNs(nsToDatabase(ns), o));
+ txn->recoveryUnit()->abandonSnapshot();
break;
}
default: