[ 
https://issues.apache.org/jira/browse/IGNITE-26691?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andrey Novikov updated IGNITE-26691:
------------------------------------
    Description: 
FetchBy is implemented in the following way in Spring Data:
{code:java}
QueryCursorWrapper<Cache.Entry<?, ?>, ?> cWrapper = new QueryCursorWrapper<>(
    (QueryCursor<Cache.Entry<?, ?>>)qryCursor, 
cWrapperTransformFunction);switch (returnStgy) {
    case PAGE_OF_VALUES:
        return new PageImpl(cWrapper.getAll(), (Pageable)prmtrs[prmtrs.length - 
1], 0);
    case LIST_OF_VALUES:
        return cWrapper.getAll();
    case STREAM_OF_VALUES:
        return cWrapper.stream();
    case ONE_VALUE:
        Iterator<?> iter1 = cWrapper.iterator();
        if (iter1.hasNext()) {
            Object resp = iter1.next();
            U.closeQuiet(cWrapper);
            return resp;
        }
        return null; {code}
returnStgy is ONE_VALUE for this case, and we close the iterator before reading 
it fully. That remains cursor state as EXECUTING and the following logic kicks 
in QueryCursorImpl
{code:java}
@Override public void close() {
    while (state != CLOSED) {
        if (STATE_UPDATER.compareAndSet(this, COMPLETED, CLOSED)) {
            closeIter();            return;
        }        if (STATE_UPDATER.compareAndSet(this, EXECUTING, CLOSED)) {
            if (cancel != null) {
                if (!cancel.multiStatement() || (cancel.multiStatement() && 
cancel.last())) {
                    cancel.cancel();
                }
            } {code}
It cancels the query after closing the cursor.

*What to do:*

Fetch all  data from the cursor or add a hasNext check, which can close the 
cursor.

  was:
FetchBy is implemented in the following way in Spring Data:
{code:java}
QueryCursorWrapper<Cache.Entry<?, ?>, ?> cWrapper = new QueryCursorWrapper<>(
    (QueryCursor<Cache.Entry<?, ?>>)qryCursor, 
cWrapperTransformFunction);switch (returnStgy) {
    case PAGE_OF_VALUES:
        return new PageImpl(cWrapper.getAll(), (Pageable)prmtrs[prmtrs.length - 
1], 0);
    case LIST_OF_VALUES:
        return cWrapper.getAll();
    case STREAM_OF_VALUES:
        return cWrapper.stream();
    case ONE_VALUE:
        Iterator<?> iter1 = cWrapper.iterator();
        if (iter1.hasNext()) {
            Object resp = iter1.next();
            U.closeQuiet(cWrapper);
            return resp;
        }
        return null; {code}
returnStgy is ONE_VALUE for this case, and we close the iterator before reading 
it fully. That remains cursor state as EXECUTING and the following logic kicks 
in QueryCursorImpl
{code:java}
@Override public void close() {
    while (state != CLOSED) {
        if (STATE_UPDATER.compareAndSet(this, COMPLETED, CLOSED)) {
            closeIter();            return;
        }        if (STATE_UPDATER.compareAndSet(this, EXECUTING, CLOSED)) {
            if (cancel != null) {
                if (!cancel.multiStatement() || (cancel.multiStatement() && 
cancel.last())) {
                    cancel.cancel();
                }
            } {code}
It cancels the query after closing the cursor.

*What to do:*

Fetch all ** data from the cursor or add a hasNext check, which can close the 
cursor.


> Get rid from warning: start to process query cancel on MAP phase.
> -----------------------------------------------------------------
>
>                 Key: IGNITE-26691
>                 URL: https://issues.apache.org/jira/browse/IGNITE-26691
>             Project: Ignite
>          Issue Type: Bug
>          Components: extensions, springdata
>            Reporter: Andrey Novikov
>            Priority: Major
>
> FetchBy is implemented in the following way in Spring Data:
> {code:java}
> QueryCursorWrapper<Cache.Entry<?, ?>, ?> cWrapper = new QueryCursorWrapper<>(
>     (QueryCursor<Cache.Entry<?, ?>>)qryCursor, 
> cWrapperTransformFunction);switch (returnStgy) {
>     case PAGE_OF_VALUES:
>         return new PageImpl(cWrapper.getAll(), (Pageable)prmtrs[prmtrs.length 
> - 1], 0);
>     case LIST_OF_VALUES:
>         return cWrapper.getAll();
>     case STREAM_OF_VALUES:
>         return cWrapper.stream();
>     case ONE_VALUE:
>         Iterator<?> iter1 = cWrapper.iterator();
>         if (iter1.hasNext()) {
>             Object resp = iter1.next();
>             U.closeQuiet(cWrapper);
>             return resp;
>         }
>         return null; {code}
> returnStgy is ONE_VALUE for this case, and we close the iterator before 
> reading it fully. That remains cursor state as EXECUTING and the following 
> logic kicks in QueryCursorImpl
> {code:java}
> @Override public void close() {
>     while (state != CLOSED) {
>         if (STATE_UPDATER.compareAndSet(this, COMPLETED, CLOSED)) {
>             closeIter();            return;
>         }        if (STATE_UPDATER.compareAndSet(this, EXECUTING, CLOSED)) {
>             if (cancel != null) {
>                 if (!cancel.multiStatement() || (cancel.multiStatement() && 
> cancel.last())) {
>                     cancel.cancel();
>                 }
>             } {code}
> It cancels the query after closing the cursor.
> *What to do:*
> Fetch all  data from the cursor or add a hasNext check, which can close the 
> cursor.



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

Reply via email to