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:14:00 UTC
[jira] [Assigned] (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 reassigned IGNITE-16158:
---------------------------------------
Assignee: Maksim Timonin
> 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
> Assignee: Maksim Timonin
> Priority: Minor
>
> ```
> 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);
> cursor.close();
> }
> ```
> QueryCursor holds a future that will be completed with iterator over result data.
> Starting a query spawns a new thread locally that query cache in background, prepares data, and it completes the future with iterator. All affected nodes run such threads.
> But cancelling of query with `QueryCursor.close` doesn't cancel query, and it will prepare data that will never request. Also cancelling of query doesn't clean up iterator.
>
> For local query 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.
>
> But for remote queries those structures spends memory. And closing of cursor has to cancel them.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)