xtern commented on code in PR #6889:
URL: https://github.com/apache/ignite-3/pull/6889#discussion_r2501969093


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/Query.java:
##########
@@ -116,6 +123,64 @@ class Query {
         this.parsedResult = parsedResult;
     }
 
+    <ResultT> CompletableFuture<ResultT> runProgram(Program<ResultT> program) {
+        ProgramExecutionState<ResultT> state = program.createState();
+
+        if (!activeProgram.compareAndSet(null, state)) {
+            throw new SqlException(Common.INTERNAL_ERR);
+        }
+
+        program.run(this, state);
+
+        return state.resultHolder;
+    }
+
+    /**
+     * Initiates a graceful termination of the current query.
+     *
+     * <p>If the query is idle, moves it to {@link ExecutionPhase#TERMINATED} 
phase immediately. Otherwise, the method waits for the
+     * currently active program to complete before proceeding. Note that 
termination may not take effect immediately upon return. To wait
+     * for the actual completion of termination, use {@link 
#terminationFuture}.
+     */
+    void terminate() {
+        tryTerminate(1);
+    }
+
+    private void tryTerminate(int attemptNo) {
+        if (attemptNo >= MAX_ATTEMPTS_COUNT) {

Review Comment:
   Just curious - can I somehow simulate repeated attempts (attempts > 2)?
   
   I mean running specific query and/or adding sleeps somewhere?)



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to