Skip to content

Commit 2cae548

Browse files
branch-4.0: [fix](variable) fix unset global variable in non-master FE #58285 (#58381)
Cherry-picked from #58285 Co-authored-by: Mingyu Chen (Rayner) <[email protected]>
1 parent 99dc707 commit 2cae548

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/UnsetVariableCommand.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.apache.doris.qe.ConnectContext;
3434
import org.apache.doris.qe.StmtExecutor;
3535
import org.apache.doris.qe.VariableMgr;
36+
import org.apache.doris.qe.VariableMgr.VarContext;
3637

3738
import org.apache.commons.lang3.StringUtils;
3839
import org.apache.logging.log4j.LogManager;
@@ -125,7 +126,12 @@ public void afterForwardToMaster(ConnectContext context) throws Exception {
125126
}
126127
SetVar var = new SetVar(SetType.SESSION, getVariable(),
127128
new StringLiteral(defaultValue), SetVar.SetVarType.SET_SESSION_VAR);
128-
VariableMgr.setVar(context.getSessionVariable(), var);
129+
VarContext varCtx = VariableMgr.getVarContext(var.getVariable());
130+
// only unset for session variable.
131+
// If this is a global variable, no need to do this because it has been synced from editlog already.
132+
if (varCtx != null && (varCtx.getFlag() & VariableMgr.SESSION) != 0) {
133+
VariableMgr.setVar(context.getSessionVariable(), var);
134+
}
129135
}
130136
}
131137

fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ public static void setVarForNonMasterFE(SessionVariable sessionVariable, SetVar
319319
}
320320

321321
@Nullable
322-
private static VarContext getVarContext(String name) {
322+
public static VarContext getVarContext(String name) {
323323
String varName = name;
324324
boolean hasExpPrefix = false;
325325
if (varName.startsWith(VariableAnnotation.EXPERIMENTAL.getPrefix())) {
@@ -893,7 +893,7 @@ public static List<List<String>> dumpChangedVars(SessionVariable sessionVar) {
893893
boolean affectQueryResult() default false;
894894
}
895895

896-
private static class VarContext {
896+
public static class VarContext {
897897
private Field field;
898898
private Object obj;
899899
private int flag;

0 commit comments

Comments
 (0)