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

Method beforeLoadingMetadata

src/Databases/DatabaseAtomic.cpp:536–565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

534}
535
536void DatabaseAtomic::beforeLoadingMetadata(ContextMutablePtr /*context*/, LoadingStrictnessLevel mode)
537{
538 auto db_disk = getDisk();
539
540 if (mode < LoadingStrictnessLevel::FORCE_RESTORE)
541 return;
542
543 if (!db_disk->isSymlinkSupported())
544 return;
545
546 // When `db_disk` is a `DiskLocal` object, `existsDirectory` will return false if the input path is a symlink.
547 // So we use `existsFileOrDirectory` here to check if the symlink exists.
548 if (!db_disk->existsFileOrDirectory(path_to_table_symlinks))
549 return;
550
551 /// Recreate symlinks to table data dirs in case of force restore, because some of them may be broken
552 for (const auto it = db_disk->iterateDirectory(path_to_table_symlinks); it->isValid(); it->next())
553 {
554 auto table_path = fs::path(it->path());
555 if (table_path.filename().empty())
556 table_path = table_path.parent_path();
557 if (!db_disk->isSymlink(table_path))
558 {
559 throw Exception(
560 ErrorCodes::ABORTED, "'{}' is not a symlink. Atomic database should contains only symlinks.", std::string(table_path));
561 }
562
563 db_disk->removeFileIfExists(table_path);
564 }
565}
566
567LoadTaskPtr DatabaseAtomic::startupDatabaseAsync(AsyncLoader & async_loader, LoadJobSet startup_after, LoadingStrictnessLevel mode)
568{

Callers 1

loadTablesAsyncMethod · 0.45

Calls 11

parent_pathMethod · 0.80
ExceptionClass · 0.50
isSymlinkSupportedMethod · 0.45
existsFileOrDirectoryMethod · 0.45
iterateDirectoryMethod · 0.45
isValidMethod · 0.45
nextMethod · 0.45
pathMethod · 0.45
emptyMethod · 0.45
isSymlinkMethod · 0.45
removeFileIfExistsMethod · 0.45

Tested by

no test coverage detected