diff --git a/core/trino-main/src/main/java/io/trino/execution/SqlQueryExecution.java b/core/trino-main/src/main/java/io/trino/execution/SqlQueryExecution.java index 14350d2c28fe..6bb5133e17cb 100644 --- a/core/trino-main/src/main/java/io/trino/execution/SqlQueryExecution.java +++ b/core/trino-main/src/main/java/io/trino/execution/SqlQueryExecution.java @@ -201,20 +201,6 @@ private SqlQueryExecution( tableExecuteContextManager.unregisterTableExecuteContextForQuery(stateMachine.getQueryId()); }); - // when the query finishes cache the final query info, and clear the reference to the output stage - AtomicReference queryScheduler = this.queryScheduler; - stateMachine.addStateChangeListener(state -> { - if (!state.isDone()) { - return; - } - - // query is now done, so abort any work that is still running - SqlQueryScheduler scheduler = queryScheduler.get(); - if (scheduler != null) { - scheduler.abort(); - } - }); - this.remoteTaskFactory = new MemoryTrackingRemoteTaskFactory(requireNonNull(remoteTaskFactory, "remoteTaskFactory is null"), stateMachine); this.typeAnalyzer = requireNonNull(typeAnalyzer, "typeAnalyzer is null"); this.coordinatorTaskManager = requireNonNull(coordinatorTaskManager, "coordinatorTaskManager is null"); @@ -530,13 +516,6 @@ private void planDistribution(PlanRoot plan) taskDescriptorStorage); queryScheduler.set(scheduler); - - // if query was canceled during scheduler creation, abort the scheduler - // directly since the callback may have already fired - if (stateMachine.isDone()) { - scheduler.abort(); - queryScheduler.set(null); - } } @Override diff --git a/core/trino-main/src/main/java/io/trino/execution/scheduler/SqlQueryScheduler.java b/core/trino-main/src/main/java/io/trino/execution/scheduler/SqlQueryScheduler.java index 5774626a0f6c..1720f9d773e0 100644 --- a/core/trino-main/src/main/java/io/trino/execution/scheduler/SqlQueryScheduler.java +++ b/core/trino-main/src/main/java/io/trino/execution/scheduler/SqlQueryScheduler.java @@ -487,17 +487,6 @@ public synchronized void cancelStage(StageId stageId) } } - public synchronized void abort() - { - try (SetThreadName ignored = new SetThreadName("Query-%s", queryStateMachine.getQueryId())) { - coordinatorStagesScheduler.abort(); - DistributedStagesScheduler distributedStagesScheduler = this.distributedStagesScheduler.get(); - if (distributedStagesScheduler != null) { - distributedStagesScheduler.abort(); - } - } - } - public void failTask(TaskId taskId, Throwable failureCause) { try (SetThreadName ignored = new SetThreadName("Query-%s", queryStateMachine.getQueryId())) {