summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/rename_collection.cpp
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2015-06-01 13:55:15 -0400
committerEric Milkie <milkie@10gen.com>2015-06-04 09:10:05 -0400
commitbc44c26302d2f377bc0cefb4e8fbffa247d18db6 (patch)
tree24335e29f9b349860a97c51331b399c41cd6edab /src/mongo/db/catalog/rename_collection.cpp
parent167d6de7241570e8bc73bcd8878fe91f1f77c12a (diff)
downloadmongo-bc44c26302d2f377bc0cefb4e8fbffa247d18db6.tar.gz
SERVER-17923 prohibit database/collection actions when bg index is running
Diffstat (limited to 'src/mongo/db/catalog/rename_collection.cpp')
-rw-r--r--src/mongo/db/catalog/rename_collection.cpp32
1 files changed, 2 insertions, 30 deletions
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();
}