Skip to content

Commit 0a9ba57

Browse files
Merge pull request ClickHouse#79235 from ClickHouse/fix-loading-of-system-logs-in-clickhouse-local
Fix loading of system logs in `clickhouse-local`
2 parents c889d40 + 986b4e8 commit 0a9ba57

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

programs/local/LocalServer.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,10 +915,14 @@ void LocalServer::processConfig()
915915

916916
if (getClientConfiguration().has("path"))
917917
{
918-
attachSystemTablesServer(global_context, *createMemoryDatabaseIfNotExists(global_context, DatabaseCatalog::SYSTEM_DATABASE), false);
919918
attachInformationSchema(global_context, *createMemoryDatabaseIfNotExists(global_context, DatabaseCatalog::INFORMATION_SCHEMA));
920919
attachInformationSchema(global_context, *createMemoryDatabaseIfNotExists(global_context, DatabaseCatalog::INFORMATION_SCHEMA_UPPERCASE));
921920

921+
/// Attaching "automatic" tables in the system database is done after attaching the system database.
922+
/// Consequently, it depends on whether we load it from the path.
923+
/// If it is loaded from a user-specified path, we load it as usual. If not, we create it as a memory (ephemeral) database.
924+
bool attached_system_database = false;
925+
922926
String path = global_context->getPath();
923927

924928
/// Lock path directory before read
@@ -933,6 +937,9 @@ void LocalServer::processConfig()
933937
{
934938
LoadTaskPtrs load_system_metadata_tasks = loadMetadataSystem(global_context);
935939
waitLoad(TablesLoaderForegroundPoolId, load_system_metadata_tasks);
940+
941+
attachSystemTablesServer(global_context, *DatabaseCatalog::instance().tryGetDatabase(DatabaseCatalog::SYSTEM_DATABASE), false);
942+
attached_system_database = true;
936943
}
937944

938945
if (!getClientConfiguration().has("only-system-tables"))
@@ -947,6 +954,9 @@ void LocalServer::processConfig()
947954

948955
LOG_DEBUG(log, "Loaded metadata.");
949956
}
957+
958+
if (!attached_system_database)
959+
attachSystemTablesServer(global_context, *createMemoryDatabaseIfNotExists(global_context, DatabaseCatalog::SYSTEM_DATABASE), false);
950960
}
951961
else if (!getClientConfiguration().has("no-system-tables"))
952962
{

0 commit comments

Comments
 (0)