From f89f4df8879ca083ea797032e556f503f9316696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Osipiuk?= Date: Sat, 2 Dec 2023 11:30:37 +0100 Subject: [PATCH] Do not fail stage after already done Ignore failure within stage execution if it already done. This is to work around the problem which was introduced with https://github.com/trinodb/trino/commit/39b04491c05. With that change we close EventDrivenTaskSource when stage completes, and as a result of that it may emit an failure event due to internall processes being cancelled. Handling of event in `StageExecution.fail()` did close a number of objects needed for query completion (see createStageExecutionCloser()). As a result the query could hang. --- .../faulttolerant/EventDrivenFaultTolerantQueryScheduler.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/trino-main/src/main/java/io/trino/execution/scheduler/faulttolerant/EventDrivenFaultTolerantQueryScheduler.java b/core/trino-main/src/main/java/io/trino/execution/scheduler/faulttolerant/EventDrivenFaultTolerantQueryScheduler.java index 6692e2ebfb93..1c8f611b7d23 100644 --- a/core/trino-main/src/main/java/io/trino/execution/scheduler/faulttolerant/EventDrivenFaultTolerantQueryScheduler.java +++ b/core/trino-main/src/main/java/io/trino/execution/scheduler/faulttolerant/EventDrivenFaultTolerantQueryScheduler.java @@ -2415,6 +2415,10 @@ public void abort() public void fail(Throwable t) { + if (stage.getState().isDone()) { + // stage already done; ignore + return; + } Closer closer = createStageExecutionCloser(); closer.register(() -> stage.fail(t)); try {