ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nikolay Izhikov <nizhi...@apache.org>
Subject How KILL QUERY should work?
Date Mon, 02 Mar 2020 09:02:34 GMT
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)
````
Mime
View raw message