summaryrefslogtreecommitdiff
path: root/src/mongo/db/cloner.cpp
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2020-04-16 13:46:46 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-04-16 18:18:47 +0000
commit44af4b2915cef5afcfe63104fb902e4519ffa889 (patch)
treeba9600e749f374377aa204d062ee357f967684b1 /src/mongo/db/cloner.cpp
parentf17cb8e9ff23d6b362e4d5d41ec27748f3a6b963 (diff)
downloadmongo-44af4b2915cef5afcfe63104fb902e4519ffa889.tar.gz
SERVER-47438 Cloner::_copyIndexes() will not recreate dropped collection
Diffstat (limited to 'src/mongo/db/cloner.cpp')
-rw-r--r--src/mongo/db/cloner.cpp28
1 files changed, 2 insertions, 26 deletions
diff --git a/src/mongo/db/cloner.cpp b/src/mongo/db/cloner.cpp
index 889d4206b97..388b3bf7e8c 100644
--- a/src/mongo/db/cloner.cpp
+++ b/src/mongo/db/cloner.cpp
@@ -285,32 +285,8 @@ void Cloner::_copyIndexes(OperationContext* opCtx,
if (from_indexes.empty())
return;
- // We are under lock here again, so reload the database in case it may have disappeared
- // during the temp release
- auto databaseHolder = DatabaseHolder::get(opCtx);
- auto db = databaseHolder->openDb(opCtx, toDBName);
-
- Collection* collection = CollectionCatalog::get(opCtx).lookupCollectionByNamespace(opCtx, nss);
- if (!collection) {
- writeConflictRetry(opCtx, "createCollection", nss.ns(), [&] {
- opCtx->checkForInterrupt();
-
- WriteUnitOfWork wunit(opCtx);
- CollectionOptions collectionOptions = uassertStatusOK(
- CollectionOptions::parse(from_opts, CollectionOptions::ParseKind::parseForCommand));
- const bool createDefaultIndexes = true;
- invariant(db->userCreateNS(opCtx,
- nss,
- collectionOptions,
- createDefaultIndexes,
- _getIdIndexSpec(from_indexes)),
- str::stream() << "Collection creation failed while copying indexes from "
- << nss << " (Cloner)");
- wunit.commit();
- collection = CollectionCatalog::get(opCtx).lookupCollectionByNamespace(opCtx, nss);
- invariant(collection, str::stream() << "Missing collection " << nss << " (Cloner)");
- });
- }
+ auto collection = CollectionCatalog::get(opCtx).lookupCollectionByNamespace(opCtx, nss);
+ invariant(collection, str::stream() << "Missing collection " << nss << " (Cloner)");
auto indexCatalog = collection->getIndexCatalog();
auto indexesToBuild = indexCatalog->removeExistingIndexesNoChecks(