You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Maksim Timonin (Jira)" <ji...@apache.org> on 2021/12/20 09:11:00 UTC

[jira] [Updated] (IGNITE-16158) QueryCursor.close CacheQuery doesn't cancel query

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

Maksim Timonin updated IGNITE-16158:
------------------------------------
    Summary: QueryCursor.close CacheQuery doesn't cancel query  (was: Cancel of local CacheQuery doesn't stop query)

> QueryCursor.close CacheQuery doesn't cancel query
> -------------------------------------------------
>
>                 Key: IGNITE-16158
>                 URL: https://issues.apache.org/jira/browse/IGNITE-16158
>             Project: Ignite
>          Issue Type: New Feature
>            Reporter: Maksim Timonin
>            Priority: Minor
>              Labels: good-first-issue, newbie
>
> ```
> IgniteCache<Long, Person> cache = crd.createCache("CACHE");
> try (IgniteDataStreamer<Long, Person> streamer = ignite.dataStreamer(cache.getName()))
> {      for (int i = 0; i < CNT; i++)            streamer.addData((long)i, new Person(i)); }
> IndexQuery<Long, Person> qry = new IndexQuery<Long, Person>(Person.class, IDX)
> .setCriteria(lt("id", CNT / 2));
> QueryCursor cursor = cache.query(qry.setLocal(true));
> cursor.close();
> }
> ```
> QueryCursor holds a future that will be completed with iterator over result data.
> Starting a query spawns a new thread that query cache in background, prepares data, and it completes the future with iterator.
> But cancelling of query with `QueryCursor.close` doesn't stops the background thread, and it will prepare data that will never request. Also cancelling of query doesn't clean up iterator. Cancellation is also invoked after cursor reaches specified query limit.
> This issue doesn't lead to any memory leaks, and the future and the iterator will be cleaned up by GC later. But actually we can help to GC by avoiding preparing the data and by explicit cleaning of those structures.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)