This commit is contained in:
Alexander Tokmakov 2022-06-21 18:47:55 +02:00
parent 13e3d40db4
commit 8288b9fe60
3 changed files with 17 additions and 4 deletions

View File

@ -174,7 +174,20 @@ void DatabaseOrdinary::loadTablesMetadata(ContextPtr local_context, ParsedTables
{ {
/// Even if we don't load the table we can still mark the uuid of it as taken. /// Even if we don't load the table we can still mark the uuid of it as taken.
if (create_query->uuid != UUIDHelpers::Nil) if (create_query->uuid != UUIDHelpers::Nil)
{
/// A bit tricky way to distinguish ATTACH DATABASE and server startup.
if (getContext()->isServerCompletelyStarted())
{
/// It's ATTACH DATABASE. UUID for permanently detached table must be already locked.
if (!DatabaseCatalog::instance().hasUUIDMapping(create_query->uuid))
throw Exception(ErrorCodes::LOGICAL_ERROR, "Cannot find UUID mapping for {}, it's a bug", create_query->uuid);
}
else
{
/// Server is starting up. Lock UUID used by permanently detached table.
DatabaseCatalog::instance().addUUIDMapping(create_query->uuid); DatabaseCatalog::instance().addUUIDMapping(create_query->uuid);
}
}
const std::string table_name = unescapeForFileName(file_name.substr(0, file_name.size() - 4)); const std::string table_name = unescapeForFileName(file_name.substr(0, file_name.size() - 4));
LOG_DEBUG(log, "Skipping permanently detached table {}.", backQuote(table_name)); LOG_DEBUG(log, "Skipping permanently detached table {}.", backQuote(table_name));

View File

@ -45,8 +45,8 @@ function check_replication_consistency()
while [[ $($CLICKHOUSE_CLIENT -q "SELECT count() FROM system.processes WHERE current_database=currentDatabase() AND query LIKE '%$table_name_prefix%'") -ne 1 ]]; do while [[ $($CLICKHOUSE_CLIENT -q "SELECT count() FROM system.processes WHERE current_database=currentDatabase() AND query LIKE '%$table_name_prefix%'") -ne 1 ]]; do
sleep 0.5; sleep 0.5;
num_tries=$((num_tries+1)) num_tries=$((num_tries+1))
if [ $num_tries -eq 100 ]; then if [ $num_tries -eq 200 ]; then
$CLICKHOUSE_CLIENT -q "SELECT count() FROM system.processes WHERE current_database=currentDatabase() AND query LIKE '%$table_name_prefix%' FORMAT Vertical" $CLICKHOUSE_CLIENT -q "SELECT * FROM system.processes WHERE current_database=currentDatabase() AND query LIKE '%$table_name_prefix%' FORMAT Vertical"
break break
fi fi
done done

View File

@ -138,7 +138,7 @@ function wait_for_queries_to_finish()
sleep 0.5; sleep 0.5;
num_tries=$((num_tries+1)) num_tries=$((num_tries+1))
if [ $num_tries -eq 20 ]; then if [ $num_tries -eq 20 ]; then
$CLICKHOUSE_CLIENT -q "SELECT count() FROM system.processes WHERE current_database=currentDatabase() AND query NOT LIKE '%system.processes%' FORMAT Vertical" $CLICKHOUSE_CLIENT -q "SELECT * FROM system.processes WHERE current_database=currentDatabase() AND query NOT LIKE '%system.processes%' FORMAT Vertical"
break break
fi fi
done done