Skip to content

Commit 7ef1f7e

Browse files
authored
[Bug](pipeline) try fix the exchange sink buffer result error (#27052)
1 parent 02f3762 commit 7ef1f7e

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

‎be/src/pipeline/task_scheduler.cpp‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -333,24 +333,29 @@ void TaskScheduler::_do_work(size_t index) {
333333
void TaskScheduler::_try_close_task(PipelineTask* task, PipelineTaskState state,
334334
Status exec_status) {
335335
auto status = task->try_close(exec_status);
336-
if (!status.ok() && state != PipelineTaskState::CANCELED) {
337-
// Call `close` if `try_close` failed to make sure allocated resources are released
338-
static_cast<void>(task->close(exec_status));
336+
auto cancel = [&]() {
339337
task->query_context()->cancel(true, status.to_string(),
340338
Status::Cancelled(status.to_string()));
341339
state = PipelineTaskState::CANCELED;
342-
} else if (task->is_pending_finish()) {
343-
task->set_state(PipelineTaskState::PENDING_FINISH);
344-
static_cast<void>(_blocked_task_scheduler->add_blocked_task(task));
345-
return;
346-
} else {
340+
};
341+
342+
auto try_close_failed = !status.ok() && state != PipelineTaskState::CANCELED;
343+
if (try_close_failed) {
344+
cancel();
345+
// Call `close` if `try_close` failed to make sure allocated resources are released
346+
static_cast<void>(task->close(exec_status));
347+
} else if (!task->is_pending_finish()) {
347348
status = task->close(exec_status);
348349
if (!status.ok() && state != PipelineTaskState::CANCELED) {
349-
task->query_context()->cancel(true, status.to_string(),
350-
Status::Cancelled(status.to_string()));
351-
state = PipelineTaskState::CANCELED;
350+
cancel();
352351
}
353352
}
353+
354+
if (task->is_pending_finish()) {
355+
task->set_state(PipelineTaskState::PENDING_FINISH);
356+
static_cast<void>(_blocked_task_scheduler->add_blocked_task(task));
357+
return;
358+
}
354359
task->set_state(state);
355360
task->set_close_pipeline_time();
356361
task->release_dependency();

0 commit comments

Comments
 (0)