xtern commented on code in PR #2846:
URL: https://github.com/apache/ignite-3/pull/2846#discussion_r1422274847
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/api/SessionImpl.java:
##########
@@ -543,55 +542,77 @@ List<AsyncSqlCursor<?>> openedCursors() {
}
private class ScriptHandler {
-
private final CompletableFuture<Void> resFut;
+ private final AtomicReference<Throwable> cursorCloseErrHolder = new
AtomicReference<>();
+
private ScriptHandler(CompletableFuture<Void> resFut) {
this.resFut = resFut;
}
- void processFirstResult(AsyncSqlCursor<InternalSqlRow> cursor,
Throwable t) {
- if (t != null) {
- resFut.completeExceptionally(t);
- } else {
- int cursorId = registerCursor(cursor);
- processCursor(cursor, cursorId);
+ void processCursor(AsyncSqlCursor<InternalSqlRow> cursor, Throwable
scriptError) {
+ if (scriptError != null) {
+ // Stop script execution.
+ completeScriptExecution(scriptError);
+
+ return;
}
+
+ cursor.closeAsync().whenComplete((ignored, cursorCloseError) -> {
+ if (cursorCloseError != null) {
+ // Just save the error for later and continue fetching
cursors.
+ saveError(cursorCloseError);
+ }
+
+ if (!busyLock.enterBusy()) {
+ completeScriptExecution(sessionIsClosedException());
+ return;
+ }
+
+ try {
+ if (cursor.hasNextResult()) {
+ cursor.nextResult().whenComplete(this::processCursor);
Review Comment:
Done but using system pool. Can you suggest what pool should be used instead?
--
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]