You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2021/12/29 12:00:21 UTC

[GitHub] [incubator-doris] xy720 commented on a change in pull request #7526: [fix](session-variable) fix bug that checkpoint may overwrite the global variables

xy720 commented on a change in pull request #7526:
URL: https://github.com/apache/incubator-doris/pull/7526#discussion_r776290428



##########
File path: fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
##########
@@ -304,17 +286,30 @@ public static void setLowerCaseTableNames(int mode) throws DdlException {
 
     // global variable persistence
     public static void write(DataOutputStream out) throws IOException {
-        defaultSessionVariable.write(out);
+        SessionVariable variablesToWrite = defaultSessionVariable;
+        if (Catalog.isCheckpointThread()) {

Review comment:
       There should not be non-checkpoint-thread calling this method. Why not directly use defaultSessionVariableForCkpt instead.

##########
File path: fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
##########
@@ -304,17 +286,30 @@ public static void setLowerCaseTableNames(int mode) throws DdlException {
 
     // global variable persistence
     public static void write(DataOutputStream out) throws IOException {
-        defaultSessionVariable.write(out);
+        SessionVariable variablesToWrite = defaultSessionVariable;
+        if (Catalog.isCheckpointThread()) {
+            // If this is checkpoint thread, we should write value in `defaultSessionVariableForCkpt` to the image
+            // instead of `defaultSessionVariable`.
+            variablesToWrite = defaultSessionVariableForCkpt;
+        }
+        variablesToWrite.write(out);
         // get all global variables
         List<String> varNames = GlobalVariable.getPersistentGlobalVarNames();
-        GlobalVarPersistInfo info = new GlobalVarPersistInfo(defaultSessionVariable, varNames);
+        GlobalVarPersistInfo info = new GlobalVarPersistInfo(variablesToWrite, varNames);
         info.write(out);
     }
 
     public static void read(DataInputStream in) throws IOException, DdlException {
         wlock.lock();
         try {
-            defaultSessionVariable.readFields(in);
+            SessionVariable variablesToRead = defaultSessionVariable;
+            if (Catalog.isCheckpointThread()) {

Review comment:
       The same as above




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org