From c933f72adb8716316df8b37200fa0dd6f9e1a2e1 Mon Sep 17 00:00:00 2001 From: Pavel Kovalenko Date: Fri, 4 Sep 2020 17:17:27 +0300 Subject: [PATCH] Disable S3 requests processing during context shutdown to speed up termination process. --- src/Disks/IDisk.h | 3 +++ src/Disks/S3/DiskS3.cpp | 5 +++++ src/Disks/S3/DiskS3.h | 2 ++ src/Interpreters/Context.cpp | 7 +++++++ 4 files changed, 17 insertions(+) diff --git a/src/Disks/IDisk.h b/src/Disks/IDisk.h index 53dc4999dc4..17de6db3487 100644 --- a/src/Disks/IDisk.h +++ b/src/Disks/IDisk.h @@ -183,6 +183,9 @@ public: /// Return disk type - "local", "s3", etc. virtual const String getType() const = 0; + /// Invoked when Global Context is shutdown. + virtual void shutdown() { } + private: /// Returns executor to perform asynchronous operations. Executor & getExecutor() { return *executor; } diff --git a/src/Disks/S3/DiskS3.cpp b/src/Disks/S3/DiskS3.cpp index 5aa57518c83..cff7cc3429a 100644 --- a/src/Disks/S3/DiskS3.cpp +++ b/src/Disks/S3/DiskS3.cpp @@ -746,4 +746,9 @@ void DiskS3::setReadOnly(const String & path) Poco::File(metadata_path + path).setReadOnly(true); } +void DiskS3::shutdown() +{ + client->DisableRequestProcessing(); +} + } diff --git a/src/Disks/S3/DiskS3.h b/src/Disks/S3/DiskS3.h index 34f00af6439..db352feb063 100644 --- a/src/Disks/S3/DiskS3.h +++ b/src/Disks/S3/DiskS3.h @@ -102,6 +102,8 @@ public: const String getType() const override { return "s3"; } + void shutdown() override; + private: bool tryReserve(UInt64 bytes); diff --git a/src/Interpreters/Context.cpp b/src/Interpreters/Context.cpp index 1318f0331c4..3f65fdb8de0 100644 --- a/src/Interpreters/Context.cpp +++ b/src/Interpreters/Context.cpp @@ -1973,6 +1973,13 @@ void Context::reloadConfig() const void Context::shutdown() { + auto disks = getDisksMap(); + for (auto & [disk_name, disk] : disks) + { + LOG_INFO(shared->log, "Shutdown disk {}", disk_name); + disk->shutdown(); + } + shared->shutdown(); }