Merge pull request #35257 from azat/fix-s3-pool-shutdown

Wait for IDiskRemote thread pool properly
This commit is contained in:
alesapin 2022-03-14 13:56:37 +01:00 committed by GitHub
commit b13b415d3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -6,6 +6,7 @@
# include <memory>
# include <vector>
# include <list>
# include <base/logger_useful.h>
# include <base/types.h>
@ -14,8 +15,6 @@
# include <aws/core/utils/memory/stl/AWSStringStream.h>
# include <Common/ThreadPool.h>
namespace Aws::S3
{
class S3Client;

View File

@ -29,6 +29,7 @@
#include <Storages/CompressionCodecSelector.h>
#include <Storages/StorageS3Settings.h>
#include <Disks/DiskLocal.h>
#include <Disks/IDiskRemote.h>
#include <TableFunctions/TableFunctionFactory.h>
#include <Interpreters/ActionLocksManager.h>
#include <Interpreters/ExternalLoaderXMLConfigRepository.h>
@ -293,6 +294,17 @@ struct ContextSharedPart
~ContextSharedPart()
{
/// Wait for thread pool for background writes,
/// since it may use per-user MemoryTracker which will be destroyed here.
try
{
IDiskRemote::getThreadPoolWriter().wait();
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
try
{
shutdown();