Nikolay,

I've made a ticket for this issue [1]

> I have one more question.
> Kill query suppose to work as the following:
> 
> 1. User execute some SQL statement.
> 2. User waits or fetch query results.
> 2. Other user(or administrator) executes «KILL QUERY» with the query id from 
> the step 1.
> 3. User receive an exception when trying to fetch more data from any server 
> node.
> 
> Is this use-case correct?

yes, I think this is a correct use case.


[1] https://issues.apache.org/jira/browse/IGNITE-12732


-- 
Kind Regards
Roman Kondakov


On 02.03.2020 14:31, Nikolay Izhikov wrote:
> Roman.
> 
>> So, the problem with this error message is solved, isn't it?
> 
> You are correct.
> 
>> The another problem you've encountered after running KILL QUERY command
>> with correct qryId is freezing. Am I correct? If yes, this is a known
>> issue and I am working on it.
> 
> Yes! Thank you for the explanation.
> Can you, please, name the ticket for this issue?
> 
> I have one more question.
> Kill query suppose to work as the following:
> 
> 1. User execute some SQL statement.
> 2. User waits or fetch query results.
> 2. Other user(or administrator) executes «KILL QUERY» with the query id from 
> the step 1.
> 3. User receive an exception when trying to fetch more data from any server 
> node.
> 
> Is this use-case correct?
> 
> 
>> 2 марта 2020 г., в 14:21, Roman Kondakov <kondako...@mail.ru.INVALID> 
>> написал(а):
>>
>> Nikolay,
>>
>> as I can see, when you run "SELECT * FROM SYS.SQL_QUERIES ORDER BY
>> START_TIME" from the client node (not from the server node as was in
>> your first reproducer), the query you are looking for is correctly
>> returned in the view's result set. Right? So, the problem with this
>> error message is solved, isn't it?
>>
>>> Error is «Query with provided ID doesn’t exist» 
>>
>> The another problem you've encountered after running KILL QUERY command
>> with correct qryId is freezing. Am I correct? If yes, this is a known
>> issue and I am working on it.
>>
>>
>> -- 
>> Kind Regards
>> Roman Kondakov
>>
>>
>> On 02.03.2020 14:02, Nikolay Izhikov wrote:
>>> Hello, Roman.
>>>
>>> Please, see updated test.
>>> I assert query text to ensure that correct `SELECT` statement used for KILL 
>>> command.
>>>
>>> This test freeze on «KILL QUERY» execution.
>>>
>>> ```
>>> @Test
>>> public void testCancelSQLQuery() throws Exception {
>>>    startGrids(1);
>>>    IgniteEx client = startClientGrid("client");
>>>
>>>    client.cluster().state(ACTIVE);
>>>
>>>    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);
>>>
>>>    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 ORDER BY START_TIME");
>>>    assertEquals(2, sqlQries0.size());
>>>
>>>    String qryId = (String)sqlQries0.get(0).get(0);
>>>    assertEquals("SELECT _KEY, _VAL FROM INTEGER", sqlQries0.get(0).get(1));
>>>
>>>    SqlViewExporterSpiTest.execute(client, "KILL QUERY '" + qryId + "'");
>>>
>>>    while(iter.hasNext())
>>>        assertNotNull(iter.next());
>>>
>>>    fail("You shouldn't be here!");
>>> }
>>> ```
>>>
>>>> 2 марта 2020 г., в 13:48, Roman Kondakov <kondako...@mail.ru.INVALID> 
>>>> написал(а):
>>>>
>>>> Nikolay,
>>>>
>>>>> This system view returns queries that are *running* on the node.
>>>>> I can see «"SELECT _KEY, _VAL FROM INTEGER» in the results of select.
>>>>
>>>> It looks a bit weird to me, because when I print results of the running
>>>> queries from server node:
>>>>
>>>> List<List<?>> sqlQries0 = SqlViewExporterSpiTest.execute(ignite0,
>>>> "SELECT * FROM SYS.SQL_QUERIES");
>>>> System.out.println("sqlQries0=" + sqlQries0);
>>>>
>>>> it prints only the system view query:
>>>>
>>>> sqlQries0=[[adfe8400-15c7-40cf-a6d2-41012b500000_1, SELECT * FROM
>>>> SYS.SQL_QUERIES, adfe8400-15c7-40cf-a6d2-41012b500000, 2020-03-02
>>>> 13:25:12.927, -3, false, PUBLIC]]
>>>>
>>>> but when I do the same for the client node, it prints both queries:
>>>>
>>>> sqlQries0=[[dbb3418d-dec2-40f4-8276-090fd31fc27d_1, SELECT _KEY, _VAL
>>>> FROM INTEGER, dbb3418d-dec2-40f4-8276-090fd31fc27d, 2020-03-02
>>>> 13:30:43.953, 17, false, default],
>>>> [dbb3418d-dec2-40f4-8276-090fd31fc27d_2, SELECT * FROM SYS.SQL_QUERIES,
>>>> dbb3418d-dec2-40f4-8276-090fd31fc27d, 2020-03-02 13:30:43.974, -4,
>>>> false, PUBLIC]]
>>>>
>>>> Are you sure you can see both queries in the result of select from the
>>>> server?
>>>>
>>>> It looks like the statement
>>>>
>>>>> This system view returns queries that are *running* on the node.
>>>>
>>>> is incorrect. The view returns queries that were *originated* from the
>>>> node, not the all *running* there. I'm not sure whether it is expected
>>>> behaviour.
>>>>
>>>>
>>>> And what about query hanging: it is a known issue. I'm working on it
>>>> right now. I'll file a ticket and propose a patch soon.
>>>>> I tried and it doesn’t work, also.
>>>>> `KILL QUERY` command just freeze on 
>>>>> `CommandProcessor#processKillQueryCommand` line 478.
>>>>
>>>>
>>>> -- 
>>>> Kind Regards
>>>> Roman Kondakov
>>>>
>>>>
>>>> On 02.03.2020 13:10, Nikolay Izhikov wrote:
>>>>> 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 <kondako...@mail.ru.INVALID> 
>>>>>> написал(а):
>>>>>>
>>>>>> 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)
>>>>>>> ````
>>>>>>>
>>>>>
>>>
> 

Reply via email to