From 696838694ce17f621b89985d29a09163f6d3417c Mon Sep 17 00:00:00 2001 From: guhanjie Date: Fri, 19 Mar 2021 10:25:00 +0800 Subject: [PATCH] Add a flag for HttpRemoteTask to avoid eager but unnecessary sendUpdate It should not sendUpdate before task been started, while the needsUpdate flag in RemoteHttpTask is not enough to ensure this, which case will happen on all non-leaf stage, as 450-470 lines in SqlStageExecution.java Although task will start soon after noMoreSplits, but we should avoid this, which is unnecessary and not strictly accurate in principle. --- .../main/java/io/trino/server/remotetask/HttpRemoteTask.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/trino-main/src/main/java/io/trino/server/remotetask/HttpRemoteTask.java b/core/trino-main/src/main/java/io/trino/server/remotetask/HttpRemoteTask.java index ee09b68eca47f..6318e5c67ba7c 100644 --- a/core/trino-main/src/main/java/io/trino/server/remotetask/HttpRemoteTask.java +++ b/core/trino-main/src/main/java/io/trino/server/remotetask/HttpRemoteTask.java @@ -159,6 +159,7 @@ public final class HttpRemoteTask private final PartitionedSplitCountTracker partitionedSplitCountTracker; + private final AtomicBoolean started = new AtomicBoolean(false); private final AtomicBoolean aborting = new AtomicBoolean(false); public HttpRemoteTask( @@ -318,6 +319,7 @@ public void start() { try (SetThreadName ignored = new SetThreadName("HttpRemoteTask-%s", taskId)) { // to start we just need to trigger an update + started.set(true); scheduleUpdate(); dynamicFiltersFetcher.start(); @@ -513,7 +515,7 @@ private synchronized void sendUpdate() { TaskStatus taskStatus = getTaskStatus(); // don't update if the task hasn't been started yet or if it is already finished - if (!needsUpdate.get() || taskStatus.getState().isDone()) { + if (!started.get() || !needsUpdate.get() || taskStatus.getState().isDone()) { return; }