Delay shutdown of system and temporary databases

This commit is contained in:
kssenii 2023-06-27 15:04:47 +02:00
parent e44b544ac0
commit 46a69829ff

View File

@ -216,8 +216,22 @@ void DatabaseCatalog::shutdownImpl()
/// We still hold "databases" (instead of std::move) for Buffer tables to flush data correctly.
/// Delay shutdown of temporary and system databases. They will be shutdown last.
std::vector<DatabasePtr> databases_with_delayed_shutdown;
for (auto & database : current_databases)
{
if (database.first == TEMPORARY_DATABASE || database.first == SYSTEM_DATABASE)
{
databases_with_delayed_shutdown.push_back(database.second);
continue;
}
database.second->shutdown();
}
for (auto & database : databases_with_delayed_shutdown)
{
database->shutdown();
}
{
std::lock_guard lock(tables_marked_dropped_mutex);