diff options
Diffstat (limited to 'src/mongo/db/s/drop_collection_coordinator.cpp')
-rw-r--r-- | src/mongo/db/s/drop_collection_coordinator.cpp | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/src/mongo/db/s/drop_collection_coordinator.cpp b/src/mongo/db/s/drop_collection_coordinator.cpp index 76b86dfeec8..11c6fe8d601 100644 --- a/src/mongo/db/s/drop_collection_coordinator.cpp +++ b/src/mongo/db/s/drop_collection_coordinator.cpp @@ -44,6 +44,24 @@ #include "mongo/s/request_types/sharded_ddl_commands_gen.h" namespace mongo { +namespace { + +void dropCollectionHonouringFromMigrateFlag(OperationContext* opCtx, + const NamespaceString& nss, + bool fromMigrate) { + if (fromMigrate) { + mongo::sharding_ddl_util::ensureCollectionDroppedNoChangeEvent(opCtx, nss); + } else { + DropReply unused; + uassertStatusOK( + dropCollection(opCtx, + nss, + &unused, + DropCollectionSystemCollectionMode::kDisallowSystemCollectionDrops)); + } +} + +} // namespace DropCollectionCoordinator::DropCollectionCoordinator(ShardingDDLCoordinatorService* service, const BSONObj& initialState) @@ -87,17 +105,18 @@ void DropCollectionCoordinator::dropCollectionLocally(OperationContext* opCtx, csr->clearFilteringMetadataForDroppedCollection(opCtx); } - DropReply unused; - if (fromMigrate) - mongo::sharding_ddl_util::ensureCollectionDroppedNoChangeEvent(opCtx, nss); - else - uassertStatusOK( - dropCollection(opCtx, - nss, - &unused, - DropCollectionSystemCollectionMode::kDisallowSystemCollectionDrops)); + try { + dropCollectionHonouringFromMigrateFlag(opCtx, nss, fromMigrate); + } catch (const ExceptionFor<ErrorCodes::NamespaceNotFound>&) { + // Note that even if the namespace was not found we have to execute the code below! + LOGV2_DEBUG(5280920, + 1, + "Namespace not found while trying to delete local collection", + "namespace"_attr = nss); + } - // Force the refresh of the catalog cache to purge outdated information + // Force the refresh of the catalog cache to purge outdated information. Note also that this + // code is indirectly used to notify to secondary nodes to clear their filtering information. const auto catalog = Grid::get(opCtx)->catalogCache(); uassertStatusOK(catalog->getCollectionRoutingInfoWithRefresh(opCtx, nss)); CatalogCacheLoader::get(opCtx).waitForCollectionFlush(opCtx, nss); |