Skip to content

Commit

Permalink
Use cancel instead of finish in case of exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Avogar committed Feb 29, 2024
1 parent 0c902f8 commit 1b8ae25
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/Processors/Executors/PipelineExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,26 +391,17 @@ void PipelineExecutor::executeImpl(size_t num_threads, bool concurrency_control)
SCOPE_EXIT_SAFE(
if (!finished_flag)
{
finish();
/// If finished_flag is not set, there was an exception.
/// Cancel execution in this case.
cancel();
if (pool)
pool->wait();
}
);

if (num_threads > 1)
{
try
{
spawnThreads(); // start at least one thread
}
catch (...)
{
/// spawnThreads can throw an exception, for example CANNOT_SCHEDULE_TASK.
/// We should cancel execution properly before rethrow.
cancel();
throw;
}

spawnThreads(); // start at least one thread
tasks.processAsyncTasks();
pool->wait();
}
Expand Down

0 comments on commit 1b8ae25

Please sign in to comment.