IGNITE-28621 SQL: Add H2 map query details to system view and logs#13091
IGNITE-28621 SQL: Add H2 map query details to system view and logs#13091chesnokoff wants to merge 10 commits into
Conversation
849559a to
83b64fc
Compare
| cursor.iterator().next(); | ||
|
|
||
| for (int i = 0; i < 2; i++) { | ||
| int nodeIdx = i; |
There was a problem hiding this comment.
effective final variable
| /** Test map query flag in running queries system view. */ | ||
| @Test | ||
| public void testMapQueryRunningQueriesView() throws Exception { | ||
| IgniteEx ignite = startGrids(2); | ||
|
|
||
| IgniteCache<Integer, String> cache = ignite.createCache( | ||
| new CacheConfiguration<Integer, String>(DEFAULT_CACHE_NAME) | ||
| .setCacheMode(CacheMode.PARTITIONED) | ||
| .setIndexedTypes(Integer.class, String.class) | ||
| ); | ||
|
|
||
| for (int i = 0; i < 10; i++) | ||
| cache.put(i, Integer.toString(i)); | ||
|
|
||
| awaitPartitionMapExchange(); | ||
|
|
||
| String initiatorId = UUID.randomUUID().toString(); | ||
|
|
||
| try (FieldsQueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery("SELECT * FROM String") | ||
| .setQueryInitiatorId(initiatorId) | ||
| .setPageSize(1))) { | ||
| cursor.iterator().next(); | ||
|
|
||
| for (int i = 0; i < 2; i++) { | ||
| int nodeIdx = i; | ||
| UUID nodeId = grid(nodeIdx).localNode().id(); | ||
|
|
||
| assertTrue(waitForCondition(() -> { | ||
| SystemView<SqlQueryView> view = grid(nodeIdx).context().systemView().view(SQL_QRY_VIEW); | ||
|
|
||
| for (SqlQueryView qry : view) { | ||
| if (qry.mapQuery() | ||
| && nodeId.equals(qry.nodeId()) | ||
| && ignite.localNode().id().equals(qry.originNodeId()) | ||
| && initiatorId.equals(qry.initiatorId())) | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| }, 5_000)); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Initially, created this test to check map queries but now I think the test may be flaky so I decided to rollback it (the test passed for visa)
There was a problem hiding this comment.
To make it non flaky you can use some user-defined function with latch or sleep.
|
Any test for SqlQueryView? |
| qry.runningFuture().onDone(); | ||
|
|
||
| qryHistTracker.collectHistory(qry, failed); | ||
| // We need to collect query history and metrics only for external SQL queries. |
There was a problem hiding this comment.
External is not a good definition here. I think something like Initiated by user is better.
|
|
||
| List<List<?>> res = node.context().query().querySqlFields( | ||
| new SqlFieldsQuery("SELECT sql, initiator_id FROM SYS.SQL_QUERIES"), false).getAll(); | ||
| new SqlFieldsQuery("SELECT sql, initiator_id FROM SYS.SQL_QUERIES WHERE MAP_QUERY = FALSE"), false).getAll(); |
There was a problem hiding this comment.
Looks like an issue. Users use initiatorId like label. Maybe it's worth to pass it together with map query request (maybe by another ticket)
| private final int segment; | ||
|
|
||
| /** Running query id. */ | ||
| private final long runningQryId; |
There was a problem hiding this comment.
Maybe "local query id"?
| /** Test map query flag in running queries system view. */ | ||
| @Test | ||
| public void testMapQueryRunningQueriesView() throws Exception { | ||
| IgniteEx ignite = startGrids(2); | ||
|
|
||
| IgniteCache<Integer, String> cache = ignite.createCache( | ||
| new CacheConfiguration<Integer, String>(DEFAULT_CACHE_NAME) | ||
| .setCacheMode(CacheMode.PARTITIONED) | ||
| .setIndexedTypes(Integer.class, String.class) | ||
| ); | ||
|
|
||
| for (int i = 0; i < 10; i++) | ||
| cache.put(i, Integer.toString(i)); | ||
|
|
||
| awaitPartitionMapExchange(); | ||
|
|
||
| String initiatorId = UUID.randomUUID().toString(); | ||
|
|
||
| try (FieldsQueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery("SELECT * FROM String") | ||
| .setQueryInitiatorId(initiatorId) | ||
| .setPageSize(1))) { | ||
| cursor.iterator().next(); | ||
|
|
||
| for (int i = 0; i < 2; i++) { | ||
| int nodeIdx = i; | ||
| UUID nodeId = grid(nodeIdx).localNode().id(); | ||
|
|
||
| assertTrue(waitForCondition(() -> { | ||
| SystemView<SqlQueryView> view = grid(nodeIdx).context().systemView().view(SQL_QRY_VIEW); | ||
|
|
||
| for (SqlQueryView qry : view) { | ||
| if (qry.mapQuery() | ||
| && nodeId.equals(qry.nodeId()) | ||
| && ignite.localNode().id().equals(qry.originNodeId()) | ||
| && initiatorId.equals(qry.initiatorId())) | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| }, 5_000)); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
To make it non flaky you can use some user-defined function with latch or sleep.
…gQueriesView" This reverts commit b3768f8.
b3768f8 to
c12268a
Compare
| String initiatorId = UUID.randomUUID().toString(); | ||
|
|
||
| IgniteInternalFuture<?> fut = GridTestUtils.runAsync(() -> | ||
| cache.query(new SqlFieldsQuery(sql).setQueryInitiatorId(initiatorId).setArgs(5_000)).getAll() |
There was a problem hiding this comment.
5 seconds sleep for each query delay test for 10 seconds. I think 1 second here is enough.
Possible compatibility issues. Please, check rolling upgrade casesThis PR modifies protected classes (with Order annotation). Affected files:
|
|




Thank you for submitting the pull request to the Apache Ignite.
In order to streamline the review of the contribution
we ask you to ensure the following steps have been taken:
The Contribution Checklist
The description explains WHAT and WHY was made instead of HOW.
The following pattern must be used:
IGNITE-XXXX Change summarywhereXXXX- number of JIRA issue.(see the Maintainers list)
the
green visaattached to the JIRA ticket (see tabPR Checkat TC.Bot - Instance 1 or TC.Bot - Instance 2)Notes
If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com #ignite channel.