From 38e8cc4bbcfb407b0d6b6c8c0ff69ee3b495300e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Dec 2024 14:58:07 +0800 Subject: [PATCH] branch-3.0: [fix](variable) force update variable not work as expected #45648 (#45695) Cherry-picked from #45648 Co-authored-by: morrySnow --- fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java | 2 +- .../src/main/java/org/apache/doris/qe/VariableMgr.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java index 027d346d0bf571..91a45bb71b07fc 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java @@ -2645,7 +2645,7 @@ public long saveGlobalVariable(CountingDataOutputStream dos, long checksum) thro } public void replayGlobalVariableV2(GlobalVarPersistInfo info) throws IOException, DdlException { - VariableMgr.replayGlobalVariableV2(info); + VariableMgr.replayGlobalVariableV2(info, false); } public long saveLoadJobsV2(CountingDataOutputStream dos, long checksum) throws IOException { diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java b/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java index 93f931fff124aa..1305b2944abae9 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java @@ -459,21 +459,21 @@ public static void read(DataInputStream in) throws IOException, DdlException { } variablesToRead.readFields(in); GlobalVarPersistInfo info = GlobalVarPersistInfo.read(in); - replayGlobalVariableV2(info); + replayGlobalVariableV2(info, true); } finally { wlock.unlock(); } } // this method is used to replace the `replayGlobalVariable()` - public static void replayGlobalVariableV2(GlobalVarPersistInfo info) throws DdlException { + public static void replayGlobalVariableV2(GlobalVarPersistInfo info, boolean fromImage) throws DdlException { wlock.lock(); try { String json = info.getPersistJsonString(); JSONObject root = (JSONObject) JSONValue.parse(json); // if not variable version, we set it to 0 to ensure we could force set global variable. boolean hasVariableVersion = root.containsKey(GlobalVariable.VARIABLE_VERSION); - if (!hasVariableVersion) { + if (fromImage && !hasVariableVersion) { GlobalVariable.variableVersion = GlobalVariable.VARIABLE_VERSION_0; } for (Object varName : root.keySet()) {