Skip to content

IGNITE-28621 SQL: Add H2 map query details to system view and logs#13091

Closed
chesnokoff wants to merge 10 commits into
apache:masterfrom
chesnokoff:ignite-28621-sql-map
Closed

IGNITE-28621 SQL: Add H2 map query details to system view and logs#13091
chesnokoff wants to merge 10 commits into
apache:masterfrom
chesnokoff:ignite-28621-sql-map

Conversation

@chesnokoff
Copy link
Copy Markdown
Contributor

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

  • There is a single JIRA ticket related to the pull request.
  • The web-link to the pull request is attached to the JIRA ticket.
  • The JIRA ticket has the Patch Available state.
  • The pull request body describes changes that have been made.
    The description explains WHAT and WHY was made instead of HOW.
  • The pull request title is treated as the final commit message.
    The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
  • A reviewer has been mentioned through the JIRA comments
    (see the Maintainers list)
  • The pull request has been checked by the Teamcity Bot and
    the green visa attached to the JIRA ticket (see tab PR Check at 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.

@chesnokoff chesnokoff force-pushed the ignite-28621-sql-map branch from 849559a to 83b64fc Compare April 30, 2026 12:22
cursor.iterator().next();

for (int i = 0; i < 2; i++) {
int nodeIdx = i;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

effective final variable

Comment on lines -684 to -726
/** 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));
}
}
}
Copy link
Copy Markdown
Contributor Author

@chesnokoff chesnokoff May 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it non flaky you can use some user-defined function with latch or sleep.

@alex-plekhanov
Copy link
Copy Markdown
Contributor

Any test for SqlQueryView?
Any test for query leakage (register - success - check that unregistered, register - throw an error on init of map phase - check that unregistered, register - throw an error on next page request - chech that unregistered)?
Any test for DML queries?

qry.runningFuture().onDone();

qryHistTracker.collectHistory(qry, failed);
// We need to collect query history and metrics only for external SQL queries.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "local query id"?

Comment on lines -684 to -726
/** 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));
}
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it non flaky you can use some user-defined function with latch or sleep.

String initiatorId = UUID.randomUUID().toString();

IgniteInternalFuture<?> fut = GridTestUtils.runAsync(() ->
cache.query(new SqlFieldsQuery(sql).setQueryInitiatorId(initiatorId).setArgs(5_000)).getAll()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 seconds sleep for each query delay test for 10 seconds. I think 1 second here is enough.

@github-actions
Copy link
Copy Markdown

Possible compatibility issues. Please, check rolling upgrade cases

This PR modifies protected classes (with Order annotation).
Changes to these classes can break rolling upgrade compatibility.

Affected files:

  • modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2DmlRequest.java

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
2 New Code Smells (required ≤ 1)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants