lowka commented on code in PR #4615: URL: https://github.com/apache/ignite-3/pull/4615#discussion_r1834407649
########## modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/QueryExecutor.java: ########## @@ -310,13 +314,26 @@ MultiStatementHandler createScriptHandler(Query query) { ); } - private void trackQuery(Query query) { + private void trackQuery(Query query, @Nullable CancellationToken cancellationToken) { Query old = runningQueries.put(query.id, query); assert old == null : "Query with the same id already registered"; - query.onPhaseStarted(ExecutionPhase.TERMINATED) - .whenComplete((ignored, ex) -> runningQueries.remove(query.id)); + CompletableFuture<Void> queryTerminationFut = query.onPhaseStarted(ExecutionPhase.TERMINATED); + + if (cancellationToken != null) { + CompletableFuture<Void> cancellationFuture = CancelHandleHelper.getCancellationFuture(cancellationToken); + CancelHandleHelper.addCancelAction(cancellationToken, query.cancel::cancel, queryTerminationFut); + + queryTerminationFut.whenComplete((ignored, ex) -> { + runningQueries.remove(query.id); + cancellationFuture.complete(null); Review Comment: Fixed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org