From d97d54d03959846dd4294c811fe89fb91d7a9d89 Mon Sep 17 00:00:00 2001 From: Antonio Fuschetto Date: Mon, 15 May 2023 13:30:45 +0000 Subject: SERVER-76983 Shutdown and join the CatalogCached's thread pool when mongos terminates --- src/mongo/s/mongos_main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mongo/s/mongos_main.cpp b/src/mongo/s/mongos_main.cpp index 4e8f3f329a9..8f0a4f7758b 100644 --- a/src/mongo/s/mongos_main.cpp +++ b/src/mongo/s/mongos_main.cpp @@ -366,6 +366,7 @@ void cleanupTask(const ShutdownTaskArgs& shutdownArgs) { } if (auto pool = Grid::get(opCtx)->getExecutorPool()) { + LOGV2_OPTIONS(7698300, {LogComponent::kSharding}, "Shutting down the ExecutorPool"); pool->shutdownAndJoin(); } @@ -374,6 +375,13 @@ void cleanupTask(const ShutdownTaskArgs& shutdownArgs) { } if (Grid::get(serviceContext)->isShardingInitialized()) { + // The CatalogCache must be shuted down before shutting down the CatalogCacheLoader as + // the CatalogCache may try to schedule work on CatalogCacheLoader and fail. + LOGV2_OPTIONS(7698301, {LogComponent::kSharding}, "Shutting down the CatalogCache"); + Grid::get(serviceContext)->catalogCache()->shutDownAndJoin(); + + LOGV2_OPTIONS( + 7698302, {LogComponent::kSharding}, "Shutting down the CatalogCacheLoader"); CatalogCacheLoader::get(serviceContext).shutDown(); } -- cgit v1.2.1