From 6e6b3722c3dfb55827fe55f17f75453698e38e21 Mon Sep 17 00:00:00 2001 From: Karol Sobczak Date: Wed, 20 Mar 2024 11:21:55 +0100 Subject: [PATCH 1/2] Remove nested if --- .../main/java/io/trino/execution/SqlTask.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/core/trino-main/src/main/java/io/trino/execution/SqlTask.java b/core/trino-main/src/main/java/io/trino/execution/SqlTask.java index 800846836218..29d08372c1e8 100644 --- a/core/trino-main/src/main/java/io/trino/execution/SqlTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/SqlTask.java @@ -372,15 +372,13 @@ else if (taskHolder.getTaskExecution() != null) { fullGcTime = taskContext.getFullGcTime(); dynamicFiltersVersion = taskContext.getDynamicFiltersVersion(); } - else { - if (state == FINISHED) { - // if task FINISHED successfully but taskHolder is not yet updated with SqlTaskExecution or FinalTaskInfo - // we are masking the state and return RUNNING. This is important so coordinator would not consider incomplete - // task information (e.g. missing proper dynamicFiltersVersion as final). - // This covers only short time window between call to SqlTaskExecution.start() and updating taskHolder reference in tryCreateSqlTaskExecution, - // so it will not add any noticable delays. - state = RUNNING; - } + else if (state == FINISHED) { + // if task FINISHED successfully but taskHolder is not yet updated with SqlTaskExecution or FinalTaskInfo + // we are masking the state and return RUNNING. This is important so coordinator would not consider incomplete + // task information (e.g. missing proper dynamicFiltersVersion as final). + // This covers only short time window between call to SqlTaskExecution.start() and updating taskHolder reference in tryCreateSqlTaskExecution, + // so it will not add any noticable delays. + state = RUNNING; } return new TaskStatus( From 087b21901c569cf9b8412b00889fa83614b1bafa Mon Sep 17 00:00:00 2001 From: Karol Sobczak Date: Wed, 20 Mar 2024 11:22:09 +0100 Subject: [PATCH 2/2] Fix formatting --- .../src/main/java/io/trino/execution/SqlTask.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/core/trino-main/src/main/java/io/trino/execution/SqlTask.java b/core/trino-main/src/main/java/io/trino/execution/SqlTask.java index 29d08372c1e8..f3418fe5418f 100644 --- a/core/trino-main/src/main/java/io/trino/execution/SqlTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/SqlTask.java @@ -218,12 +218,9 @@ else if (newState.isDone()) { switch (newState) { // don't close buffers for a failed query // closed buffers signal to upstream tasks that everything finished cleanly - case FAILED, FAILING, ABORTED, ABORTING -> - outputBuffer.abort(); - case FINISHED, CANCELED, CANCELING -> - outputBuffer.destroy(); - default -> - throw new IllegalStateException(format("Invalid state for output buffer destruction: %s", newState)); + case FAILED, FAILING, ABORTED, ABORTING -> outputBuffer.abort(); + case FINISHED, CANCELED, CANCELING -> outputBuffer.destroy(); + default -> throw new IllegalStateException(format("Invalid state for output buffer destruction: %s", newState)); } } }