MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / initializeImpl

Method initializeImpl

src/Interpreters/FileCache/FileCache.cpp:446–481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

444}
445
446void FileCache::initializeImpl(bool load_metadata)
447{
448 std::lock_guard lock(init_mutex);
449
450 if (is_initialized)
451 return;
452
453 try
454 {
455 /// Publish the invalidate notifier before loadMetadata spawns threads that can invalidate entries.
456 main_priority->startup(Context::getGlobalContextInstance()->getSchedulePool(), cache_guard);
457
458 if (load_metadata)
459 loadMetadata();
460
461 metadata.startup();
462 }
463 catch (...)
464 {
465 /// startup() may have scheduled the background cleanup task; stop it so a retried
466 /// initialization does not leave an orphaned task rescheduling on `this`.
467 main_priority->deactivateBackgroundOperations();
468 init_exception = std::current_exception();
469 tryLogCurrentException(__PRETTY_FUNCTION__);
470 throw;
471 }
472
473 if (keep_current_size_to_max_ratio != 1 || keep_current_elements_to_max_ratio != 1)
474 {
475 keep_up_free_space_ratio_task = Context::getGlobalContextInstance()->getSchedulePool().createTask(StorageID::createEmpty(), log->name(), [this] { freeSpaceRatioKeepingThreadFunc(); });
476 keep_up_free_space_ratio_task->schedule();
477 }
478
479 is_initialized = true;
480 LOG_TEST(log, "Initialized cache from {}", metadata.getBaseDirectory());
481}
482
483CachePriorityGuard::WriteLock FileCache::lockCache() const
484{

Callers

nothing calls this directly

Calls 8

loadMetadataFunction · 0.85
createEmptyFunction · 0.85
tryLogCurrentExceptionFunction · 0.50
startupMethod · 0.45
createTaskMethod · 0.45
nameMethod · 0.45
scheduleMethod · 0.45

Tested by

no test coverage detected