[config](Nereids): add SessionVariable to control nereids timeout (#30048)
This commit is contained in:
@ -19,6 +19,7 @@ package org.apache.doris.nereids.jobs.scheduler;
|
||||
|
||||
import org.apache.doris.nereids.CascadesContext;
|
||||
import org.apache.doris.nereids.jobs.Job;
|
||||
import org.apache.doris.qe.SessionVariable;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -29,11 +30,14 @@ public class SimpleJobScheduler implements JobScheduler {
|
||||
@Override
|
||||
public void executeJobPool(ScheduleContext scheduleContext) {
|
||||
JobPool pool = scheduleContext.getJobPool();
|
||||
CascadesContext context = (CascadesContext) scheduleContext;
|
||||
SessionVariable sessionVariable = context.getConnectContext().getSessionVariable();
|
||||
while (!pool.isEmpty()) {
|
||||
CascadesContext context = (CascadesContext) scheduleContext;
|
||||
if (context.getConnectContext().getSessionVariable().enableNereidsTimeout
|
||||
&& context.getStatementContext().getStopwatch().elapsed(TimeUnit.MILLISECONDS) > 5000) {
|
||||
throw new RuntimeException("Nereids cost too much time ( > 5s )");
|
||||
if (sessionVariable.enableNereidsTimeout
|
||||
&& context.getStatementContext().getStopwatch().elapsed(TimeUnit.MILLISECONDS)
|
||||
> sessionVariable.nereidsTimeoutSecond * 1000L) {
|
||||
throw new RuntimeException(
|
||||
"Nereids cost too much time ( > " + sessionVariable.nereidsTimeoutSecond + "s )");
|
||||
}
|
||||
Job job = pool.pop();
|
||||
job.execute();
|
||||
|
||||
@ -1155,6 +1155,9 @@ public class SessionVariable implements Serializable, Writable {
|
||||
@VariableMgr.VarAttr(name = ENABLE_NEREIDS_TIMEOUT, needForward = true)
|
||||
public boolean enableNereidsTimeout = true;
|
||||
|
||||
@VariableMgr.VarAttr(name = "nereids_timeout_second", needForward = true)
|
||||
public int nereidsTimeoutSecond = 5;
|
||||
|
||||
@VariableMgr.VarAttr(name = ENABLE_PUSH_DOWN_NO_GROUP_AGG)
|
||||
public boolean enablePushDownNoGroupAgg = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user