mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 16:50:48 +00:00
Merge pull request #16769 from nikitamikhaylov/better_exception_ddl
Better exception DDL
This commit is contained in:
commit
f207d5dc21
@ -1465,11 +1465,16 @@ BackgroundSchedulePool & Context::getDistributedSchedulePool()
|
||||
return *shared->distributed_schedule_pool;
|
||||
}
|
||||
|
||||
bool Context::hasDistributedDDL() const
|
||||
{
|
||||
return getConfigRef().has("distributed_ddl");
|
||||
}
|
||||
|
||||
void Context::setDDLWorker(std::unique_ptr<DDLWorker> ddl_worker)
|
||||
{
|
||||
auto lock = getLock();
|
||||
if (shared->ddl_worker)
|
||||
throw Exception("DDL background thread has already been initialized.", ErrorCodes::LOGICAL_ERROR);
|
||||
throw Exception("DDL background thread has already been initialized", ErrorCodes::LOGICAL_ERROR);
|
||||
shared->ddl_worker = std::move(ddl_worker);
|
||||
}
|
||||
|
||||
@ -1477,7 +1482,15 @@ DDLWorker & Context::getDDLWorker() const
|
||||
{
|
||||
auto lock = getLock();
|
||||
if (!shared->ddl_worker)
|
||||
throw Exception("DDL background thread is not initialized.", ErrorCodes::NO_ELEMENTS_IN_CONFIG);
|
||||
{
|
||||
if (!hasZooKeeper())
|
||||
throw Exception("There is no Zookeeper configuration in server config", ErrorCodes::NO_ELEMENTS_IN_CONFIG);
|
||||
|
||||
if (!hasDistributedDDL())
|
||||
throw Exception("There is no DistributedDDL configuration in server config", ErrorCodes::NO_ELEMENTS_IN_CONFIG);
|
||||
|
||||
throw Exception("DDL background thread is not initialized", ErrorCodes::NO_ELEMENTS_IN_CONFIG);
|
||||
}
|
||||
return *shared->ddl_worker;
|
||||
}
|
||||
|
||||
|
@ -523,6 +523,8 @@ public:
|
||||
BackgroundSchedulePool & getSchedulePool();
|
||||
BackgroundSchedulePool & getDistributedSchedulePool();
|
||||
|
||||
/// Has distributed_ddl configuration or not.
|
||||
bool hasDistributedDDL() const;
|
||||
void setDDLWorker(std::unique_ptr<DDLWorker> ddl_worker);
|
||||
DDLWorker & getDDLWorker() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user