From 83873bdbe4df59cc3320f49567166cc5f3455be6 Mon Sep 17 00:00:00 2001 From: Karol Sobczak Date: Fri, 14 Oct 2022 11:50:39 +0200 Subject: [PATCH] Do not compare finished and all tasks sets eagerly --- .../trino/execution/scheduler/PipelinedStageExecution.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/trino-main/src/main/java/io/trino/execution/scheduler/PipelinedStageExecution.java b/core/trino-main/src/main/java/io/trino/execution/scheduler/PipelinedStageExecution.java index 9e3466693d5e..585df264979d 100644 --- a/core/trino-main/src/main/java/io/trino/execution/scheduler/PipelinedStageExecution.java +++ b/core/trino-main/src/main/java/io/trino/execution/scheduler/PipelinedStageExecution.java @@ -60,6 +60,7 @@ import java.util.stream.Stream; import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.ImmutableSet.toImmutableSet; import static io.airlift.http.client.HttpUriBuilder.uriBuilderFrom; @@ -395,7 +396,11 @@ private synchronized boolean isStageFlushing() private synchronized boolean isStageFinished() { - return finishedTasks.containsAll(allTasks); + boolean finished = finishedTasks.size() == allTasks.size(); + if (finished) { + checkState(finishedTasks.containsAll(allTasks), "Finished tasks should contain all tasks"); + } + return finished; } private boolean addFlushingTask(TaskId taskId)