IGNITE-26596 Add the DURATION_TOTAL field to the SQL_QUERIES_HISTORY system view#12544
IGNITE-26596 Add the DURATION_TOTAL field to the SQL_QUERIES_HISTORY system view#12544oleg-vlsk wants to merge 3 commits intoapache:masterfrom
Conversation
| long expTotalTime = totalTimeArr[0] * totalTimeArr.length; | ||
| long actTotalTime = totalTimeArr[1]; | ||
|
|
||
| assertEquals(expTotalTime, actTotalTime, expTotalTime * 0.2); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Changed to the sleep time check.
| * | ||
| */ | ||
| @QuerySqlFunction | ||
| public static int sleep_func(int sleep, int val) { |
There was a problem hiding this comment.
Let's return boolean without second parameter.
| try { | ||
| Thread.sleep(sleep); | ||
| } | ||
| catch (InterruptedException ignored) { | ||
| // No-op | ||
| } |
There was a problem hiding this comment.
doSleep(sleep);
Let's also add:
GridTestClockTimer.update();
To ensure that U.currentTimeMillis() is updated and difference between currentTimeMillis calls always exceeds sleep time.
| */ | ||
| @Test | ||
| public void testSqlFieldsQueryTotalDuration() { | ||
| SqlFieldsQuery qry = new SqlFieldsQuery("select * from A.String where _key=sleep_func(?, ?)").setArgs(500, 1); |
There was a problem hiding this comment.
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.
| if (totalTime > curTotalTime.get()) { | ||
| curTotalTime.set(totalTime); | ||
|
|
||
| totalTimeArr[finI] = totalTime; | ||
|
|
||
| return true; | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Corrected the check.
| IgniteInternalFuture<?> fut = GridTestUtils.runAsync( | ||
| () -> cache.query(new SqlFieldsQuery("select * from test where waitLatch(10000)")).getAll()); | ||
|
|
||
| U.sleep(500); |
There was a problem hiding this comment.
Let's add:
GridTestClockTimer.update();
To ensure that U.currentTimeMillis() is updated and difference between currentTimeMillis calls always exceeds sleep time.
|



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 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.