Hello, Roman.
My initial query was about correct usage of KILL QUERY command.
It seems for me, that It just doesn’t work.
> itself, which is already completed by the time you run "KILL QUERY" command.
As you can see from the source iterator doesn’t closed in the moment of `KILL
QUERY` execution.
I suppose that should mean that query still executed.
> returns only the queries which were originated from the ignite0 node.
This system view returns queries that are *running* on the node.
I can see «"SELECT _KEY, _VAL FROM INTEGER» in the results of select.
I suppose that mean that query are executed on the server node.
> Try to replace "ignite0" with a "client" node in this line. I think it may
> help
I tried and it doesn’t work, also.
`KILL QUERY` command just freeze on `CommandProcessor#processKillQueryCommand`
line 478.
```
/** @throws Exception If failed. */
@Test
public void testCancelSQLQuery() throws Exception {
IgniteEx ignite0 = startGrids(NODES_CNT);
IgniteEx client = startClientGrid("client");
ignite0.cluster().state(ACTIVE);
initCache(client);
SqlFieldsQuery qry = new SqlFieldsQuery("SELECT _KEY, _VAL FROM
INTEGER").setSchema("default").setPageSize(10);
Iterator<List<?>> iter = queryProcessor(client).querySqlFields(qry,
true).iterator();
assertNotNull(iter.next());
List<List<?>> sqlQries0 = SqlViewExporterSpiTest.execute(client, "SELECT *
FROM SYS.SQL_QUERIES");
assertEquals(2, sqlQries0.size());
String qryId = (String)sqlQries0.get(0).get(0);
assertEquals("SELECT _KEY, _VAL FROM INTEGER", sqlQries0.get(0).get(1));
//Here test just freeze.
SqlViewExporterSpiTest.execute(client, "KILL QUERY '" + qryId + "'");
while(iter.hasNext())
assertNotNull(iter.next());
fail("You shouldn't be here!");
}
``
> 2 марта 2020 г., в 12:46, Roman Kondakov <[email protected]>
> написал(а):
>
> Hi Nikolay,
>
> I think that problem here is that the query you are trying to kill is
>
>> "SELECT QUERY_ID FROM SYS.SQL_QUERIES"
>
> itself, which is already completed by the time you run "KILL QUERY" command.
>
> I'm not an expert in the system views, but it seems to me that the line
>
>> List<List<?>> sqlQries0 = SqlViewExporterSpiTest.execute(ignite0, "SELECT
>> QUERY_ID FROM SYS.SQL_QUERIES");
>
> returns only the queries which were originated from the ignite0 node.
> Since "SELECT _KEY, _VAL FROM INTEGER" was started on the client node,
> it doesn't get into that list.
>
> Try to replace "ignite0" with a "client" node in this line. I think it
> may help:
>
>> List<List<?>> sqlQries0 = SqlViewExporterSpiTest.execute(client, "SELECT
>> QUERY_ID FROM SYS.SQL_QUERIES");
>
>
>
> --
> Kind Regards
> Roman Kondakov
>
>
> On 02.03.2020 12:02, Nikolay Izhikov wrote:
>> Hello, Igniters.
>>
>> Ignite right now support `KILL QUERY` command.
>> I tried to use it and stuck with the simple test.
>> Error is «Query with provided ID doesn’t exist»
>>
>> Can you, please, advise me - How KILL QUERY should be used?
>>
>> ```
>> @Test
>> public void testCancelSQLQuery() throws Exception {
>> IgniteEx ignite0 = startGrids(NODES_CNT);
>> IgniteEx client = startClientGrid("client");
>>
>> ignite0.cluster().state(ACTIVE);
>>
>> initCache(client);
>>
>> SqlFieldsQuery qry = new SqlFieldsQuery("SELECT _KEY, _VAL FROM
>> INTEGER").setSchema("default").setPageSize(10);
>> Iterator<List<?>> iter = queryProcessor(client).querySqlFields(qry,
>> true).iterator();
>>
>> assertNotNull(iter.next());
>>
>> List<List<?>> sqlQries0 = SqlViewExporterSpiTest.execute(ignite0,
>> "SELECT QUERY_ID FROM SYS.SQL_QUERIES");
>> assertEquals(1, sqlQries0.size());
>>
>> String qryId = (String)sqlQries0.get(0).get(0);
>> SqlViewExporterSpiTest.execute(client, "KILL QUERY '" + qryId + "'»);
>>
>> //Expecting this iteration will fail.
>> while(iter.hasNext())
>> assertNotNull(iter.next());
>>
>> fail("You shouldn't be here!");
>> }
>>
>> private void initCache(IgniteEx client) {
>> IgniteCache<Object, Object> cache = client.getOrCreateCache(
>> new
>> CacheConfiguration<>(DEFAULT_CACHE_NAME).setIndexedTypes(Integer.class,
>> Integer.class));
>>
>> for (int i = 0; i < PAGE_SZ * PAGE_SZ; i++)
>> cache.put(i, i);
>> }
>> ```
>>
>> ```
>> class org.apache.ignite.internal.processors.query.IgniteSQLException: Failed
>> to cancel query
>> [nodeId=4f812490-47b9-4331-8b51-d783f5300000,qryId=1,err=Query with provided
>> ID doesn't exist [nodeId=4f812490-47b9-4331-8b51-d783f5300000, qryId=1]]
>>
>> at
>> org.apache.ignite.internal.processors.query.h2.CommandProcessor.processKillQueryCommand(CommandProcessor.java:482)
>> at
>> org.apache.ignite.internal.processors.query.h2.CommandProcessor.runCommand(CommandProcessor.java:411)
>> at
>> org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.executeCommand(IgniteH2Indexing.java:996)
>> at
>> org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.querySqlFields(IgniteH2Indexing.java:1085)
>> at
>> org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:2454)
>> ````
>>