fix for Replicated database recovery

This commit is contained in:
Alexander Tokmakov 2023-03-22 18:12:42 +01:00
parent 0989dd837a
commit b70216f9f1

View File

@ -928,7 +928,16 @@ void DatabaseReplicated::recoverLostReplica(const ZooKeeperPtr & current_zookeep
for (const auto & table_id : tables_to_create) for (const auto & table_id : tables_to_create)
{ {
auto table_name = table_id.getTableName(); auto table_name = table_id.getTableName();
auto create_query_string = table_name_to_metadata[table_name]; auto metadata_it = table_name_to_metadata.find(table_name);
if (metadata_it == table_name_to_metadata.end())
{
/// getTablesSortedByDependency() may return some not existing tables or tables from other databases
LOG_WARNING(log, "Got table name {} when resolving table dependencies, "
"but database {} does not have metadata for that table. Ignoring it", table_id.getNameForLogs(), getDatabaseName());
continue;
}
const auto & create_query_string = metadata_it->second;
if (isTableExist(table_name, getContext())) if (isTableExist(table_name, getContext()))
{ {
assert(create_query_string == readMetadataFile(table_name)); assert(create_query_string == readMetadataFile(table_name));