diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2020-10-30 10:26:10 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-11-10 19:56:46 +0000 |
commit | 83162ebfc508346a283463053d858dd7dfe6d97d (patch) | |
tree | be91045f00252e430f09e9dd92969f2f84ba7e6d /src/mongo/db/catalog/index_catalog_impl.cpp | |
parent | e618ffe3d88cf7193f1210476a592d55eeb2613d (diff) | |
download | mongo-83162ebfc508346a283463053d858dd7dfe6d97d.tar.gz |
SERVER-51895 Fix so drop index is registering a valid ident with the reaper when possible
Also fix so the drop pending ident reaper is used in standalone mode
Diffstat (limited to 'src/mongo/db/catalog/index_catalog_impl.cpp')
-rw-r--r-- | src/mongo/db/catalog/index_catalog_impl.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp index 6ba972ea18e..ddf67684ecc 100644 --- a/src/mongo/db/catalog/index_catalog_impl.cpp +++ b/src/mongo/db/catalog/index_catalog_impl.cpp @@ -1071,32 +1071,26 @@ Status IndexCatalogImpl::dropIndexEntry(OperationContext* opCtx, IndexCatalogEnt } CollectionQueryInfo::get(_collection).droppedIndex(opCtx, _collection, indexName); - entry = nullptr; - deleteIndexFromDisk(opCtx, indexName); + _deleteIndexFromDisk(opCtx, indexName, entry->getSharedIdent()); return Status::OK(); } void IndexCatalogImpl::deleteIndexFromDisk(OperationContext* opCtx, const string& indexName) { invariant(opCtx->lockState()->isCollectionLockedForMode(_collection->ns(), MODE_X)); + _deleteIndexFromDisk(opCtx, indexName, nullptr); +} - // The index catalog entry may not exist in the catalog depending on how far an index build may - // have gotten before needing to abort. If the catalog entry cannot be found, then there are no - // concurrent operations still using the index. - auto ident = [&]() -> std::shared_ptr<Ident> { - auto indexDesc = findIndexByName(opCtx, indexName, true /* includeUnfinishedIndexes */); - if (!indexDesc) { - return nullptr; - } - return getEntry(indexDesc)->accessMethod()->getSharedIdent(); - }(); - +void IndexCatalogImpl::_deleteIndexFromDisk(OperationContext* opCtx, + const string& indexName, + std::shared_ptr<Ident> ident) { + invariant(!findIndexByName(opCtx, indexName, true /* includeUnfinishedIndexes*/)); catalog::removeIndex(opCtx, indexName, _collection->getCatalogId(), _collection->uuid(), _collection->ns(), - ident); + std::move(ident)); } void IndexCatalogImpl::setMultikeyPaths(OperationContext* const opCtx, |