Exception on double init of global thread pool

This commit is contained in:
Alexander Kuzmenkov 2020-09-15 13:29:47 +03:00
parent bd14c79b0b
commit d943bac1a4

View File

@ -13,6 +13,7 @@ namespace DB
namespace ErrorCodes
{
extern const int CANNOT_SCHEDULE_TASK;
extern const int LOGICAL_ERROR;
}
}
@ -276,7 +277,11 @@ std::unique_ptr<GlobalThreadPool> GlobalThreadPool::the_instance;
void GlobalThreadPool::initialize(size_t max_threads)
{
assert(!the_instance);
if (the_instance)
{
throw Exception(LOGICAL_ERROR,
"The global thread pool is initialized twice");
}
the_instance.reset(new GlobalThreadPool(max_threads,
1000 /*max_free_threads*/, 10000 /*max_queue_size*/,