From ee8b3339a11adc2e76bdc199bd188934fb3fdafe Mon Sep 17 00:00:00 2001 From: nikitamikhaylov Date: Fri, 6 Nov 2020 21:28:59 +0300 Subject: [PATCH 1/2] done --- src/Interpreters/Context.cpp | 17 +++++++++++++++-- src/Interpreters/Context.h | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Interpreters/Context.cpp b/src/Interpreters/Context.cpp index 94ebd397f51..6275e37953b 100644 --- a/src/Interpreters/Context.cpp +++ b/src/Interpreters/Context.cpp @@ -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 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; } diff --git a/src/Interpreters/Context.h b/src/Interpreters/Context.h index a2b61b29514..de7f7488a7c 100644 --- a/src/Interpreters/Context.h +++ b/src/Interpreters/Context.h @@ -523,6 +523,8 @@ public: BackgroundSchedulePool & getSchedulePool(); BackgroundSchedulePool & getDistributedSchedulePool(); + /// Has distributed_ddl configuration or not. + bool hasDistributedDDL() const; void setDDLWorker(std::unique_ptr ddl_worker); DDLWorker & getDDLWorker() const; From 6f4e5bcaac2916b94c04f3333accb1ad5b060a02 Mon Sep 17 00:00:00 2001 From: nikitamikhaylov Date: Thu, 12 Nov 2020 23:11:04 +0300 Subject: [PATCH 2/2] style --- src/Interpreters/Context.cpp | 2 +- src/Interpreters/Context.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Interpreters/Context.cpp b/src/Interpreters/Context.cpp index 6275e37953b..54ee7713e95 100644 --- a/src/Interpreters/Context.cpp +++ b/src/Interpreters/Context.cpp @@ -1465,7 +1465,7 @@ BackgroundSchedulePool & Context::getDistributedSchedulePool() return *shared->distributed_schedule_pool; } -bool Context::hasDistributedDDL() const +bool Context::hasDistributedDDL() const { return getConfigRef().has("distributed_ddl"); } diff --git a/src/Interpreters/Context.h b/src/Interpreters/Context.h index de7f7488a7c..02a57b5d966 100644 --- a/src/Interpreters/Context.h +++ b/src/Interpreters/Context.h @@ -523,7 +523,7 @@ public: BackgroundSchedulePool & getSchedulePool(); BackgroundSchedulePool & getDistributedSchedulePool(); - /// Has distributed_ddl configuration or not. + /// Has distributed_ddl configuration or not. bool hasDistributedDDL() const; void setDDLWorker(std::unique_ptr ddl_worker); DDLWorker & getDDLWorker() const;