diff options
author | Benety Goh <benety@mongodb.com> | 2020-04-16 13:46:46 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-17 20:14:53 +0000 |
commit | 68e3f4ee266273a9dad7ccfd5cbed5e4d9bcb324 (patch) | |
tree | c032a1c7da2c4f6c9d562c5922748281bae2f47d /src/mongo | |
parent | b3ade64366311783f002d83b5b6ab746608339b0 (diff) | |
download | mongo-68e3f4ee266273a9dad7ccfd5cbed5e4d9bcb324.tar.gz |
SERVER-47438 Cloner::_copyIndexes() will not recreate dropped collection
(cherry picked from commit 44af4b2915cef5afcfe63104fb902e4519ffa889)
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/cloner.cpp | 28 |
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( |