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(); }