[enhance](session)check invalid value when set parallel instance variables (#28141)
in some case, if set incorrectly, will be cause BE core dump
10:18:19 *** SIGFPE integer divide by zero (@0x564853c204c8) received by PID 2132555
int max_scanners =
config::doris_scanner_thread_pool_thread_num / state->query_parallel_instance_num();
This commit is contained in:
@ -682,10 +682,12 @@ public class SessionVariable implements Serializable, Writable {
|
||||
* the parallel exec instance num for one Fragment in one BE
|
||||
* 1 means disable this feature
|
||||
*/
|
||||
@VariableMgr.VarAttr(name = PARALLEL_FRAGMENT_EXEC_INSTANCE_NUM, needForward = true, fuzzy = true)
|
||||
@VariableMgr.VarAttr(name = PARALLEL_FRAGMENT_EXEC_INSTANCE_NUM, needForward = true, fuzzy = true,
|
||||
setter = "setFragmentInstanceNum")
|
||||
public int parallelExecInstanceNum = 1;
|
||||
|
||||
@VariableMgr.VarAttr(name = PARALLEL_PIPELINE_TASK_NUM, fuzzy = true, needForward = true)
|
||||
@VariableMgr.VarAttr(name = PARALLEL_PIPELINE_TASK_NUM, fuzzy = true, needForward = true,
|
||||
setter = "setPipelineTaskNum")
|
||||
public int parallelPipelineTaskNum = 0;
|
||||
|
||||
@VariableMgr.VarAttr(name = PROFILE_LEVEL, fuzzy = true)
|
||||
@ -1860,6 +1862,26 @@ public class SessionVariable implements Serializable, Writable {
|
||||
this.queryTimeoutS = this.maxExecutionTimeMS / 1000;
|
||||
}
|
||||
|
||||
public void setPipelineTaskNum(String value) throws Exception {
|
||||
int val = checkFieldValue(PARALLEL_PIPELINE_TASK_NUM, 0, value);
|
||||
this.parallelPipelineTaskNum = val;
|
||||
}
|
||||
|
||||
public void setFragmentInstanceNum(String value) throws Exception {
|
||||
int val = checkFieldValue(PARALLEL_FRAGMENT_EXEC_INSTANCE_NUM, 1, value);
|
||||
this.parallelExecInstanceNum = val;
|
||||
}
|
||||
|
||||
private int checkFieldValue(String variableName, int minValue, String value) throws Exception {
|
||||
int val = Integer.valueOf(value);
|
||||
if (val < minValue) {
|
||||
throw new Exception(
|
||||
variableName + " value should greater than or equal " + String.valueOf(minValue)
|
||||
+ ", you set value is: " + value);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public String getWorkloadGroup() {
|
||||
return workloadGroup;
|
||||
}
|
||||
|
||||
@ -52,6 +52,7 @@ import java.io.IOException;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
@ -153,6 +154,7 @@ public class VariableMgr {
|
||||
// Set value to a variable
|
||||
private static boolean setValue(Object obj, Field field, String value) throws DdlException {
|
||||
VarAttr attr = field.getAnnotation(VarAttr.class);
|
||||
|
||||
if (VariableVarConverters.hasConverter(attr.name())) {
|
||||
value = VariableVarConverters.encode(attr.name(), value).toString();
|
||||
}
|
||||
@ -169,6 +171,8 @@ public class VariableMgr {
|
||||
Preconditions.checkArgument(obj instanceof SessionVariable);
|
||||
try {
|
||||
SessionVariable.class.getDeclaredMethod(attr.setter(), String.class).invoke(obj, value);
|
||||
} catch (InvocationTargetException e) {
|
||||
ErrorReport.reportDdlException(((InvocationTargetException) e).getTargetException().getMessage());
|
||||
} catch (Exception e) {
|
||||
ErrorReport.reportDdlException(ErrorCode.ERR_INVALID_VALUE, attr.name(), value, e.getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user