diff --git a/src/Interpreters/Cache/FileCache.cpp b/src/Interpreters/Cache/FileCache.cpp index 95dc9ba016b..6788ad2d2af 100644 --- a/src/Interpreters/Cache/FileCache.cpp +++ b/src/Interpreters/Cache/FileCache.cpp @@ -34,8 +34,6 @@ FileCache::FileCache(const FileCacheSettings & settings) if (settings.enable_filesystem_query_cache_limit) query_limit = std::make_unique(); - - cleanup_task = Context::getGlobalContextInstance()->getSchedulePool().createTask("FileCacheCleanup", [this]{ cleanupThreadFunc(); }); } FileCache::Key FileCache::createKeyForPath(const String & path) @@ -99,6 +97,8 @@ void FileCache::initialize() } is_initialized = true; + + cleanup_task = Context::getGlobalContextInstance()->getSchedulePool().createTask("FileCacheCleanup", [this]{ cleanupThreadFunc(); }); cleanup_task->activate(); cleanup_task->scheduleAfter(delayed_cleanup_interval_ms); }