alex-plekhanov commented on code in PR #13091:
URL: https://github.com/apache/ignite/pull/13091#discussion_r3189417082
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/query/running/RunningQueryManager.java:
##########
@@ -375,26 +439,28 @@ public void unregister(long qryId, @Nullable Throwable
failReason) {
if (failed)
qrySpan.addTag(ERROR, failReason::getMessage);
- //We need to collect query history and metrics only for SQL
queries.
Review Comment:
Looks like we can replace all futher changes in this method with just:
```
if (qry.mapQuery())
return;
```
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/query/running/GridRunningQueryInfo.java:
##########
@@ -33,9 +33,12 @@ public class GridRunningQueryInfo {
/** */
private final long id;
- /** Originating Node ID. */
+ /** Node that owns query. */
private final UUID nodeId;
Review Comment:
Such renaming is not quite correct. Global query id still uses `nodeId` as
originator node. Performance statistics use `nodeId` as originator node (yes,
it's currently only collected for reduce node, but it still not correct to pass
`current node` as `originator node`). Also I'm not sure we need `current node`
field at all. Maybe we should keep old naming and pass originator node id to
this field for map queries.
##########
modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java:
##########
@@ -567,6 +589,8 @@ private void onQueryRequest0(
if (qryInfo != null)
h2.heavyQueriesTracker().stopTracking(qryInfo, e);
+ h2.runningQueryManager().unregister(runningQryId, e);
Review Comment:
Do we need to unregister also in `onNextPageRequest` (in case of error)?
##########
modules/clients/src/test/java/org/apache/ignite/common/RunningQueryInfoCheckInitiatorTest.java:
##########
@@ -336,7 +336,7 @@ private String initiatorId(IgniteEx node, String sqlMatch,
int timeout) throws E
fail("Timeout. Cannot find query with: " + sqlMatch);
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();
Review 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)
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/query/running/RunningQueryManager.java:
##########
@@ -375,26 +439,28 @@ public void unregister(long qryId, @Nullable Throwable
failReason) {
if (failed)
qrySpan.addTag(ERROR, failReason::getMessage);
- //We need to collect query history and metrics only for SQL
queries.
if (isSqlQuery(qry)) {
qry.runningFuture().onDone();
- qryHistTracker.collectHistory(qry, failed);
+ // We need to collect query history and metrics only for
external SQL queries.
Review Comment:
`External` is not a good definition here. I think something like `Initiated
by user` is better.
##########
modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/MapH2QueryInfo.java:
##########
@@ -30,11 +30,15 @@ public class MapH2QueryInfo extends H2QueryInfo {
/** Segment. */
private final int segment;
+ /** Running query id. */
+ private final long runningQryId;
Review Comment:
Maybe "local query id"?
##########
modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlSystemViewsSelfTest.java:
##########
@@ -681,50 +681,6 @@ public void testRunningQueriesViewDuration() throws
Exception {
}
}
- /** 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));
- }
- }
- }
Review Comment:
To make it non flaky you can use some user-defined function with latch or
sleep.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]