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

Maksim Timonin updated IGNITE-13237:
------------------------------------
    Description: 
{{CacheQueryExecutedEvent}} fires for all query types (Scan, SQL) but in some 
SQL cases (ddl queries, updates and commands) {{IgniteClient#query}} does not .
 Reproducer:
{code:java|title=IgniteCacheAbstractQuerySelfTest.java}
@Test
public void testClientSqlQueryEvents() throws Exception {
    CountDownLatch execLatch = new CountDownLatch(9);

    IgnitePredicate<Event> lsnr = evt -> {
        assert evt instanceof CacheQueryExecutedEvent;

        System.out.println(">>> EVENT: " + evt);

        CacheQueryExecutedEvent qe = (CacheQueryExecutedEvent)evt;

        assertEquals("SQL_PUBLIC_TEST_TABLE", qe.cacheName());
        assertNotNull(qe.clause());
        assertNull(qe.scanQueryFilter());
        assertNull(qe.continuousQueryFilter());

        execLatch.countDown();

        return true;
    };

    ignite().events().localListen(lsnr, EVT_CACHE_QUERY_EXECUTED);

    ClientConfiguration cc = new 
ClientConfiguration().setAddresses(Config.SERVER);

    try (IgniteClient client = Ignition.startClient(cc)) {
        client.query(new SqlFieldsQuery("create table TEST_TABLE(key int 
primary key, val int)"))
            .getAll();

        client.query(new SqlFieldsQuery("insert into TEST_TABLE values (?, 
?)").setArgs(1, 1))
            .getAll();

        client.query(new SqlFieldsQuery("update TEST_TABLE set val = ?2 where 
key = ?1").setArgs(1, 2))
            .getAll();

        client.query(new SqlFieldsQuery("select * from TEST_TABLE"))
            .getAll();

        client.query(new SqlFieldsQuery("create index idx_1 on 
TEST_TABLE(key)"))
            .getAll();

        client.query(new SqlFieldsQuery("drop index idx_1"))
            .getAll();

        client.query(new SqlFieldsQuery("alter table TEST_TABLE add column val2 
int"))
            .getAll();

        client.query(new SqlFieldsQuery("alter table TEST_TABLE drop val2"))
            .getAll();

        client.query(new SqlFieldsQuery("drop table TEST_TABLE"))
            .getAll();

        assertTrue(execLatch.await(3_000, MILLISECONDS));
    }
    finally {
        ignite().events().stopLocalListen(lsnr, EVT_CACHE_QUERY_EXECUTED);
    }
}
{code}

  was:
In some cases (ddl queries, updates and commands) {{IgniteClient#query}} does 
not fire {{CacheQueryExecutedEvent}}.
 Reproducer:
{code:java|title=IgniteCacheAbstractQuerySelfTest.java}
@Test
public void testClientSqlQueryEvents() throws Exception {
    CountDownLatch execLatch = new CountDownLatch(9);

    IgnitePredicate<Event> lsnr = evt -> {
        assert evt instanceof CacheQueryExecutedEvent;

        System.out.println(">>> EVENT: " + evt);

        CacheQueryExecutedEvent qe = (CacheQueryExecutedEvent)evt;

        assertEquals("SQL_PUBLIC_TEST_TABLE", qe.cacheName());
        assertNotNull(qe.clause());
        assertNull(qe.scanQueryFilter());
        assertNull(qe.continuousQueryFilter());

        execLatch.countDown();

        return true;
    };

    ignite().events().localListen(lsnr, EVT_CACHE_QUERY_EXECUTED);

    ClientConfiguration cc = new 
ClientConfiguration().setAddresses(Config.SERVER);

    try (IgniteClient client = Ignition.startClient(cc)) {
        client.query(new SqlFieldsQuery("create table TEST_TABLE(key int 
primary key, val int)"))
            .getAll();

        client.query(new SqlFieldsQuery("insert into TEST_TABLE values (?, 
?)").setArgs(1, 1))
            .getAll();

        client.query(new SqlFieldsQuery("update TEST_TABLE set val = ?2 where 
key = ?1").setArgs(1, 2))
            .getAll();

        client.query(new SqlFieldsQuery("select * from TEST_TABLE"))
            .getAll();

        client.query(new SqlFieldsQuery("create index idx_1 on 
TEST_TABLE(key)"))
            .getAll();

        client.query(new SqlFieldsQuery("drop index idx_1"))
            .getAll();

        client.query(new SqlFieldsQuery("alter table TEST_TABLE add column val2 
int"))
            .getAll();

        client.query(new SqlFieldsQuery("alter table TEST_TABLE drop val2"))
            .getAll();

        client.query(new SqlFieldsQuery("drop table TEST_TABLE"))
            .getAll();

        assertTrue(execLatch.await(3_000, MILLISECONDS));
    }
    finally {
        ignite().events().stopLocalListen(lsnr, EVT_CACHE_QUERY_EXECUTED);
    }
}
{code}


> In some cases IgniteClient#query does not fire CacheQueryExecutedEvent
> ----------------------------------------------------------------------
>
>                 Key: IGNITE-13237
>                 URL: https://issues.apache.org/jira/browse/IGNITE-13237
>             Project: Ignite
>          Issue Type: Task
>            Reporter: Ryabov Dmitrii
>            Assignee: Ryabov Dmitrii
>            Priority: Trivial
>             Fix For: 2.10
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> {{CacheQueryExecutedEvent}} fires for all query types (Scan, SQL) but in some 
> SQL cases (ddl queries, updates and commands) {{IgniteClient#query}} does not 
> .
>  Reproducer:
> {code:java|title=IgniteCacheAbstractQuerySelfTest.java}
> @Test
> public void testClientSqlQueryEvents() throws Exception {
>     CountDownLatch execLatch = new CountDownLatch(9);
>     IgnitePredicate<Event> lsnr = evt -> {
>         assert evt instanceof CacheQueryExecutedEvent;
>         System.out.println(">>> EVENT: " + evt);
>         CacheQueryExecutedEvent qe = (CacheQueryExecutedEvent)evt;
>         assertEquals("SQL_PUBLIC_TEST_TABLE", qe.cacheName());
>         assertNotNull(qe.clause());
>         assertNull(qe.scanQueryFilter());
>         assertNull(qe.continuousQueryFilter());
>         execLatch.countDown();
>         return true;
>     };
>     ignite().events().localListen(lsnr, EVT_CACHE_QUERY_EXECUTED);
>     ClientConfiguration cc = new 
> ClientConfiguration().setAddresses(Config.SERVER);
>     try (IgniteClient client = Ignition.startClient(cc)) {
>         client.query(new SqlFieldsQuery("create table TEST_TABLE(key int 
> primary key, val int)"))
>             .getAll();
>         client.query(new SqlFieldsQuery("insert into TEST_TABLE values (?, 
> ?)").setArgs(1, 1))
>             .getAll();
>         client.query(new SqlFieldsQuery("update TEST_TABLE set val = ?2 where 
> key = ?1").setArgs(1, 2))
>             .getAll();
>         client.query(new SqlFieldsQuery("select * from TEST_TABLE"))
>             .getAll();
>         client.query(new SqlFieldsQuery("create index idx_1 on 
> TEST_TABLE(key)"))
>             .getAll();
>         client.query(new SqlFieldsQuery("drop index idx_1"))
>             .getAll();
>         client.query(new SqlFieldsQuery("alter table TEST_TABLE add column 
> val2 int"))
>             .getAll();
>         client.query(new SqlFieldsQuery("alter table TEST_TABLE drop val2"))
>             .getAll();
>         client.query(new SqlFieldsQuery("drop table TEST_TABLE"))
>             .getAll();
>         assertTrue(execLatch.await(3_000, MILLISECONDS));
>     }
>     finally {
>         ignite().events().stopLocalListen(lsnr, EVT_CACHE_QUERY_EXECUTED);
>     }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to