mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Merge pull request #3643 from yandex/fix-parallel-inputs-processor-deadlock
Fix deadlock in ParallelInputsProcessor in case thread creation fails.
This commit is contained in:
commit
733ab51089
@ -107,9 +107,27 @@ public:
|
||||
active_threads = max_threads;
|
||||
threads.reserve(max_threads);
|
||||
auto thread_group = CurrentThread::getGroup();
|
||||
|
||||
try
|
||||
{
|
||||
for (size_t i = 0; i < max_threads; ++i)
|
||||
threads.emplace_back([=] () { thread(thread_group, i); } );
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
cancel(false);
|
||||
wait();
|
||||
if (active_threads)
|
||||
{
|
||||
active_threads = 0;
|
||||
/// handler.onFinish() is supposed to be called from one of the threads when the number of
|
||||
/// finished threads reaches max_threads. But since we weren't able to launch all threads,
|
||||
/// we have to call onFinish() manually here.
|
||||
handler.onFinish();
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// Ask all sources to stop earlier than they run out.
|
||||
void cancel(bool kill)
|
||||
|
Loading…
Reference in New Issue
Block a user