mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Merge pull request #13557 from ClickHouse/load-metadata-better-error-messages
Better error messages in loadMetadata
This commit is contained in:
commit
dbccea1d92
@ -142,7 +142,6 @@ void DatabaseOrdinary::loadStoredObjects(Context & context, bool has_force_resto
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
iterateMetadataFiles(context, process_metadata);
|
iterateMetadataFiles(context, process_metadata);
|
||||||
|
|
||||||
size_t total_tables = file_names.size() - total_dictionaries;
|
size_t total_tables = file_names.size() - total_dictionaries;
|
||||||
|
@ -100,7 +100,6 @@ BlockIO InterpreterCreateQuery::createDatabase(ASTCreateQuery & create)
|
|||||||
throw Exception("Database " + database_name + " already exists.", ErrorCodes::DATABASE_ALREADY_EXISTS);
|
throw Exception("Database " + database_name + " already exists.", ErrorCodes::DATABASE_ALREADY_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Will write file with database metadata, if needed.
|
/// Will write file with database metadata, if needed.
|
||||||
String database_name_escaped = escapeForFileName(database_name);
|
String database_name_escaped = escapeForFileName(database_name);
|
||||||
fs::path metadata_path = fs::canonical(context.getPath());
|
fs::path metadata_path = fs::canonical(context.getPath());
|
||||||
|
@ -70,8 +70,16 @@ static void loadDatabase(
|
|||||||
database_attach_query = "CREATE DATABASE " + backQuoteIfNeed(database);
|
database_attach_query = "CREATE DATABASE " + backQuoteIfNeed(database);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
executeCreateQuery(database_attach_query, context, database,
|
executeCreateQuery(database_attach_query, context, database,
|
||||||
database_metadata_file, force_restore_data);
|
database_metadata_file, force_restore_data);
|
||||||
|
}
|
||||||
|
catch (Exception & e)
|
||||||
|
{
|
||||||
|
e.addMessage(fmt::format("while loading database {} from path {}", backQuote(database), database_path));
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -80,6 +88,8 @@ static void loadDatabase(
|
|||||||
|
|
||||||
void loadMetadata(Context & context, const String & default_database_name)
|
void loadMetadata(Context & context, const String & default_database_name)
|
||||||
{
|
{
|
||||||
|
Poco::Logger * log = &Poco::Logger::get("loadMetadata");
|
||||||
|
|
||||||
String path = context.getPath() + "metadata";
|
String path = context.getPath() + "metadata";
|
||||||
|
|
||||||
/** There may exist 'force_restore_data' file, that means,
|
/** There may exist 'force_restore_data' file, that means,
|
||||||
@ -106,6 +116,22 @@ void loadMetadata(Context & context, const String & default_database_name)
|
|||||||
if (db_name != SYSTEM_DATABASE)
|
if (db_name != SYSTEM_DATABASE)
|
||||||
databases.emplace(unescapeForFileName(db_name), path + "/" + db_name);
|
databases.emplace(unescapeForFileName(db_name), path + "/" + db_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Temporary fails may be left from previous server runs.
|
||||||
|
if (endsWith(it.name(), ".tmp"))
|
||||||
|
{
|
||||||
|
LOG_WARNING(log, "Removing temporary file {}", it->path());
|
||||||
|
try
|
||||||
|
{
|
||||||
|
it->remove();
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
/// It does not prevent server to startup.
|
||||||
|
tryLogCurrentException(log);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user