Skip to content

Commit

Permalink
branch-2.1: [fix](variable) force update variable not work as expected
Browse files Browse the repository at this point in the history
…apache#45648 (apache#45696)

Cherry-picked from apache#45648

Co-authored-by: morrySnow <[email protected]>
  • Loading branch information
github-actions[bot] and morrySnow authored Dec 20, 2024
1 parent 37c4de3 commit 17cc76e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
Original file line number Diff line number Diff line change
Expand Up @@ -2514,7 +2514,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 {
Expand Down
6 changes: 3 additions & 3 deletions fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit 17cc76e

Please sign in to comment.