[ 
https://issues.apache.org/jira/browse/IGNITE-26789?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18031437#comment-18031437
 ] 

Pavel Pereslegin commented on IGNITE-26789:
-------------------------------------------

This is happened due to incorrect implementation of resources releasing in 
ClientSqlCommon.saveNextResultResource.
{{releaseRunnable}} in ClientResource must close not only current cursor but 
fetch all remaining cursors and close them (similarly how 
IgniteSqlImpl.ScriptHandler does this).
Example (not production ready):
instead of
{code:java}
ClientResource resource = new ClientResource(
        new CursorWithPageSize(nextResultFuture, pageSize),
        () -> nextResultFuture.thenApply(AsyncCursor::closeAsync));
{code}
use
{code:java}
ClientResource resource = new ClientResource(
        new CursorWithPageSize(nextResultFuture, pageSize),
        () -> {
            List<AsyncSqlCursor<?>> cursors = new ArrayList<>();
            var traverser = new Function<AsyncSqlCursor<?>, 
CompletableFuture<AsyncSqlCursor<?>>>() {
                @Override
                public CompletableFuture<AsyncSqlCursor<?>> 
apply(AsyncSqlCursor<?> cursor) {
                    cursors.add(cursor);

                    if (cursor.hasNextResult()) {
                        return cursor.nextResult().thenCompose(this);
                    }

                    return null;
                }
            };

            nextResultFuture
                    .thenCompose(traverser)
                    .whenComplete((r, ignore) -> {
                        for (AsyncSqlCursor<?> cur : cursors) {
                            cur.closeAsync();
                        }
                    });
        }
);
{code}


> Jdbc. Script statement cursors do not close when client disconnects
> -------------------------------------------------------------------
>
>                 Key: IGNITE-26789
>                 URL: https://issues.apache.org/jira/browse/IGNITE-26789
>             Project: Ignite
>          Issue Type: Bug
>          Components: jdbc ai3
>            Reporter: Maksim Zhuravkov
>            Priority: Major
>              Labels: ignite-3
>             Fix For: 3.2
>
>
> Closing the client does not close script statement cursor on the server (see 
> ItJdbcClusterPerIntegrationTest noResourcesScriptAfterClientTerminates)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to