mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
do CREATE query async
This commit is contained in:
parent
93cf15dba2
commit
2920f04fff
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include <Core/Defines.h>
|
#include <Core/Defines.h>
|
||||||
#include <Core/SettingsEnums.h>
|
#include <Core/SettingsEnums.h>
|
||||||
|
#include <Core/ServerSettings.h>
|
||||||
|
|
||||||
#include <IO/WriteBufferFromFile.h>
|
#include <IO/WriteBufferFromFile.h>
|
||||||
#include <IO/WriteHelpers.h>
|
#include <IO/WriteHelpers.h>
|
||||||
@ -324,8 +325,20 @@ BlockIO InterpreterCreateQuery::createDatabase(ASTCreateQuery & create)
|
|||||||
{
|
{
|
||||||
/// We use global context here, because storages lifetime is bigger than query context lifetime
|
/// We use global context here, because storages lifetime is bigger than query context lifetime
|
||||||
TablesLoader loader{getContext()->getGlobalContext(), {{database_name, database}}, mode};
|
TablesLoader loader{getContext()->getGlobalContext(), {{database_name, database}}, mode};
|
||||||
waitLoad(currentPoolOr(AsyncLoaderPoolId::Foreground), loader.loadTablesAsync());
|
auto load_tasks = loader.loadTablesAsync();
|
||||||
waitLoad(currentPoolOr(AsyncLoaderPoolId::Foreground), loader.startupTablesAsync());
|
auto startup_tasks = loader.startupTablesAsync();
|
||||||
|
if (getContext()->getGlobalContext()->getServerSettings().async_load_databases)
|
||||||
|
{
|
||||||
|
scheduleLoad(load_tasks);
|
||||||
|
scheduleLoad(startup_tasks);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/// First prioritize, schedule and wait all the load table tasks
|
||||||
|
waitLoad(currentPoolOr(AsyncLoaderPoolId::Foreground), load_tasks);
|
||||||
|
/// Only then prioritize, schedule and wait all the startup tasks
|
||||||
|
waitLoad(currentPoolOr(AsyncLoaderPoolId::Foreground), startup_tasks);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
|
Loading…
Reference in New Issue
Block a user