From 59a14d2a509a45de46066bfc8e0a9ad3327d35a7 Mon Sep 17 00:00:00 2001 From: Alexander Tokmakov Date: Fri, 24 Jun 2022 17:34:41 +0200 Subject: [PATCH] add docs --- .../settings.md | 29 +++++++++++++++++++ src/Interpreters/DatabaseCatalog.cpp | 5 +++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/docs/en/operations/server-configuration-parameters/settings.md b/docs/en/operations/server-configuration-parameters/settings.md index ad879679a3d..d3a50969a39 100644 --- a/docs/en/operations/server-configuration-parameters/settings.md +++ b/docs/en/operations/server-configuration-parameters/settings.md @@ -193,6 +193,35 @@ Sets the delay before remove table data in seconds. If the query has `SYNC` modi Default value: `480` (8 minute). +## database_catalog_unused_dir_hide_timeout_sec {#database_catalog_unused_dir_hide_timeout_sec} + +Parameter of a task that cleans up garbage from `store/` directory. +If some subdirectory is not used by clickhouse-server and this directory was not modified for last +`database_catalog_unused_dir_hide_timeout_sec` seconds, the task will "hide" this directory by +removing all access rights. It also works for directories that clickhouse-server does not +expect to see inside `store/`. Zero means "immediately". + +Default value: `3600` (1 hour). + +## database_catalog_unused_dir_rm_timeout_sec {#database_catalog_unused_dir_rm_timeout_sec} + +Parameter of a task that cleans up garbage from `store/` directory. +If some subdirectory is not used by clickhouse-server and it was previousely "hidden" +(see [database_catalog_unused_dir_hide_timeout_sec](../../operations/server-configuration-parameters/settings.md#database_catalog_unused_dir_hide_timeout_sec)) +and this directory was not modified for last +`database_catalog_unused_dir_rm_timeout_sec` seconds, the task will remove this directory. +It also works for directories that clickhouse-server does not +expect to see inside `store/`. Zero means "never". + +Default value: `2592000` (30 days). + +## database_catalog_unused_dir_cleanup_period_sec {#database_catalog_unused_dir_cleanup_period_sec} + +Parameter of a task that cleans up garbage from `store/` directory. +Sets scheduling period of the task. Zero means "never". + +Default value: `86400` (1 day). + ## default_database {#default-database} The default database. diff --git a/src/Interpreters/DatabaseCatalog.cpp b/src/Interpreters/DatabaseCatalog.cpp index 1df3bf30396..13340221f38 100644 --- a/src/Interpreters/DatabaseCatalog.cpp +++ b/src/Interpreters/DatabaseCatalog.cpp @@ -156,7 +156,7 @@ void DatabaseCatalog::initializeAndLoadTemporaryDatabase() void DatabaseCatalog::loadDatabases() { - if (Context::getGlobalContextInstance()->getApplicationType() == Context::ApplicationType::SERVER) + if (Context::getGlobalContextInstance()->getApplicationType() == Context::ApplicationType::SERVER && unused_dir_cleanup_period_sec) { auto cleanup_task_holder = getContext()->getSchedulePool().createTask("DatabaseCatalog", [this]() { this->cleanupStoreDirectoryTask(); }); @@ -1219,6 +1219,9 @@ bool DatabaseCatalog::maybeRemoveDirectory(const fs::path & unused_dir) } else { + if (!unused_dir_rm_timeout_sec) + return false; + if (current_time <= max_modification_time + unused_dir_rm_timeout_sec) return false;