summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/storage_interface_impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/repl/storage_interface_impl.cpp')
-rw-r--r--src/mongo/db/repl/storage_interface_impl.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp
index 4127ad6b410..a6e9efc5011 100644
--- a/src/mongo/db/repl/storage_interface_impl.cpp
+++ b/src/mongo/db/repl/storage_interface_impl.cpp
@@ -493,6 +493,30 @@ Status StorageInterfaceImpl::createCollection(OperationContext* opCtx,
});
}
+Status StorageInterfaceImpl::createIndexesOnEmptyCollection(
+ OperationContext* opCtx,
+ const NamespaceString& nss,
+ const std::vector<BSONObj>& secondaryIndexSpecs) {
+ return writeConflictRetry(opCtx, "createIndexesOnEmptyCollection", nss.ns(), [&] {
+ AutoGetCollection autoColl(opCtx, nss, fixLockModeForSystemDotViewsChanges(nss, MODE_IX));
+ WriteUnitOfWork wunit(opCtx);
+
+ for (auto&& spec : secondaryIndexSpecs) {
+ // Will error if collection is not empty.
+ auto secIndexSW =
+ autoColl.getCollection()->getIndexCatalog()->createIndexOnEmptyCollection(opCtx,
+ spec);
+ auto status = secIndexSW.getStatus();
+ if (!status.isOK()) {
+ return status;
+ }
+ }
+
+ wunit.commit();
+ return Status::OK();
+ });
+}
+
Status StorageInterfaceImpl::dropCollection(OperationContext* opCtx, const NamespaceString& nss) {
return writeConflictRetry(opCtx, "StorageInterfaceImpl::dropCollection", nss.ns(), [&] {
AutoGetDb autoDb(opCtx, nss.db(), MODE_IX);