This commit is contained in:
Alexander Tokmakov 2022-06-24 17:34:41 +02:00
parent 379fecf7f9
commit 59a14d2a50
2 changed files with 33 additions and 1 deletions

View File

@ -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.

View File

@ -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;