Skip to content

IGNITE-26596 Add the DURATION_TOTAL field to the SQL_QUERIES_HISTORY system view#12544

Closed
oleg-vlsk wants to merge 3 commits intoapache:masterfrom
oleg-vlsk:IGNITE-26596
Closed

IGNITE-26596 Add the DURATION_TOTAL field to the SQL_QUERIES_HISTORY system view#12544
oleg-vlsk wants to merge 3 commits intoapache:masterfrom
oleg-vlsk:IGNITE-26596

Conversation

@oleg-vlsk
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 TC.Bot: Check PR)

Notes

If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com #ignite channel.

Comment on lines +284 to +287
long expTotalTime = totalTimeArr[0] * totalTimeArr.length;
long actTotalTime = totalTimeArr[1];

assertEquals(expTotalTime, actTotalTime, expTotalTime * 0.2);
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 it's better to rely on original sleep time? Something like:

        assertTrue(totalTimeArr[0] >= 500);
        assertTrue(totalTimeArr[1] >= totalTimeArr[0] + 500);

Relying on totalTimeArr[0] * totalTimeArr.length looks fragile.

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.

Changed to the sleep time check.

*
*/
@QuerySqlFunction
public static int sleep_func(int sleep, int val) {
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.

Let's return boolean without second parameter.

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.

Done.

Comment on lines +712 to +717
try {
Thread.sleep(sleep);
}
catch (InterruptedException ignored) {
// No-op
}
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.

doSleep(sleep);

Let's also add:

GridTestClockTimer.update();

To ensure that U.currentTimeMillis() is updated and difference between currentTimeMillis calls always exceeds sleep time.

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.

Done.

*/
@Test
public void testSqlFieldsQueryTotalDuration() {
SqlFieldsQuery qry = new SqlFieldsQuery("select * from A.String where _key=sleep_func(?, ?)").setArgs(500, 1);
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.

Whis query has no guarantees that sleep_func will be executed only once. At least sleep_func will be executed on each node. Let's rewrite to something like:

SqlFieldsQuery qry = new SqlFieldsQuery("select * from A.String where _key=0 and sleep_func(?)").setArgs(500);

Or

SqlFieldsQuery qry = new SqlFieldsQuery("select sleep_func(?) from A.String where _key=0").setArgs(500);

In this case partition pruning will be applied, and only one node with only one entry will be selected.

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.

Done.

Comment on lines +1073 to +1079
if (totalTime > curTotalTime.get()) {
curTotalTime.set(totalTime);

totalTimeArr[finI] = totalTime;

return true;
}
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.

Let's simplify checks:

                if (totalTime >= curTotalTime.get() + 500) {
                    curTotalTime.set(totalTime);

                    return true;
                }

totalTimeArr is not required anymore, assertEquals at the end of the method is not required too.

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.

Corrected the check.

IgniteInternalFuture<?> fut = GridTestUtils.runAsync(
() -> cache.query(new SqlFieldsQuery("select * from test where waitLatch(10000)")).getAll());

U.sleep(500);
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.

Let's add:

GridTestClockTimer.update();

To ensure that U.currentTimeMillis() is updated and difference between currentTimeMillis calls always exceeds sleep time.

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.

Done.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Dec 2, 2025

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants