Skip to content

Commit

Permalink
[BugFix] Fix check of plan timeout in SeriallyTaskScheduler (#48405)
Browse files Browse the repository at this point in the history
Signed-off-by: zihe.liu <[email protected]>
(cherry picked from commit 6132193)

# Conflicts:
#	fe/fe-core/src/test/java/com/starrocks/sql/plan/ReplayFromDumpTest.java
  • Loading branch information
ZiheLiu authored and mergify[bot] committed Jul 16, 2024
1 parent 9e59bd3 commit 07c725c
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public static TaskScheduler create() {
@Override
public void executeTasks(TaskContext context) {
long timeout = context.getOptimizerContext().getSessionVariable().getOptimizerExecuteTimeout();
long watch = context.getOptimizerContext().optimizerElapsedMs();
while (!tasks.empty()) {
long watch = context.getOptimizerContext().optimizerElapsedMs();
if (timeout > 0 && watch > timeout) {
// Should have at least one valid plan
// group will be null when in rewrite phase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.starrocks.common.profile.Tracers;
import com.starrocks.qe.SessionVariable;
import com.starrocks.qe.VariableMgr;
import com.starrocks.sql.common.StarRocksPlannerException;
import com.starrocks.sql.optimizer.OptExpression;
import com.starrocks.sql.optimizer.OptimizerContext;
import com.starrocks.sql.optimizer.base.CTEProperty;
Expand Down Expand Up @@ -166,7 +167,6 @@ public void testTPCDS23_1() throws Exception {
" | other join predicates: CAST(118: sum AS DOUBLE) > CAST(0.5 * 190: max AS DOUBLE)"));
}


@Test
public void testGroupByLimit() throws Exception {
// check can generate 1 phase with limit 1
Expand Down Expand Up @@ -752,6 +752,21 @@ public void testJoinWithArray() throws Exception {
" | TABLE: tbl_mock_024"));
}

<<<<<<< HEAD
=======
@Test
public void testTwoStageAgg() throws Exception {
Pair<QueryDumpInfo, String> replayPair =
getPlanFragment(getDumpInfoFromFile("query_dump/two_stage_agg"),
null, TExplainLevel.COSTS);
Assert.assertTrue(replayPair.second, replayPair.second.contains("1:AGGREGATE (update serialize)\n" +
" | STREAMING"));

Assert.assertTrue(replayPair.second, replayPair.second.contains("0:OlapScanNode\n" +
" table: lineorder_2, rollup: lineorder_2"));
}

>>>>>>> 6132193b24 ([BugFix] Fix check of plan timeout in SeriallyTaskScheduler (#48405))
@Test
public void testPushDistinctAggDownWindow() throws Exception {
Pair<QueryDumpInfo, String> replayPair =
Expand Down Expand Up @@ -935,4 +950,50 @@ public void testTimeoutDeepJoinCostPrune() throws Exception {
long count = Long.parseLong(ss.substring(start, end));
Assert.assertTrue(ss, count < 10000);
}
<<<<<<< HEAD
=======

@Test
public void testDistinctConstantRewrite() throws Exception {
Pair<QueryDumpInfo, String> replayPair =
getPlanFragment(getDumpInfoFromFile("query_dump/distinct_constant"),
connectContext.getSessionVariable(), TExplainLevel.NORMAL);
Assert.assertTrue(replayPair.second, replayPair.second.contains("4:AGGREGATE (update serialize)\n" +
" | output: multi_distinct_count(1)"));
Assert.assertTrue(replayPair.second, replayPair.second.contains("9:AGGREGATE (update serialize)\n" +
" | output: multi_distinct_count(NULL)"));
}

@Test
public void testSplitOrderBy() throws Exception {
Pair<QueryDumpInfo, String> replayPair =
getPlanFragment(getDumpInfoFromFile("query_dump/split_order_by"),
null, TExplainLevel.NORMAL);
Assert.assertTrue(replayPair.second, replayPair.second.contains("21:MERGING-EXCHANGE"));
Assert.assertTrue(replayPair.second, replayPair.second.contains("20:TOP-N"));
Assert.assertTrue(replayPair.second, replayPair.second.contains("15:MERGING-EXCHANGE"));
Assert.assertTrue(replayPair.second, replayPair.second.contains("14:TOP-N"));

}

@Test
public void testQueryCacheSetOperator() throws Exception {

String savedSv = connectContext.getSessionVariable().getJsonString();
try {
connectContext.getSessionVariable().setEnableQueryCache(true);
QueryDumpInfo dumpInfo = getDumpInfoFromJson(getDumpInfoFromFile("query_dump/query_cache_set_operator"));
ExecPlan execPlan = UtFrameUtils.getPlanFragmentFromQueryDump(connectContext, dumpInfo);
Assert.assertTrue(execPlan.getFragments().stream().anyMatch(frag -> frag.getCacheParam() != null));
} finally {
connectContext.getSessionVariable().replayFromJson(savedSv);
}
}

@Test
public void testQueryTimeout() {
Assert.assertThrows(StarRocksPlannerException.class,
() -> getPlanFragment(getDumpInfoFromFile("query_dump/query_timeout"), null, TExplainLevel.NORMAL));
}
>>>>>>> 6132193b24 ([BugFix] Fix check of plan timeout in SeriallyTaskScheduler (#48405))
}
Loading

0 comments on commit 07c725c

Please sign in to comment.