This is an automated email from the ASF dual-hosted git repository.

w41ter pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new b1393150a49 [opt] (binlog) Support Modify ViewDef binlog #41167 
(#44519)
b1393150a49 is described below

commit b1393150a490a87e10b1dfb3e402965a429dd0ac
Author: walter <maoch...@selectdb.com>
AuthorDate: Tue Nov 26 10:34:12 2024 +0800

    [opt] (binlog) Support Modify ViewDef binlog #41167 (#44519)
    
    cherry pick from #41167
    
    ---------
    
    Co-authored-by: yanmingfu <133083714+xiaoming12...@users.noreply.github.com>
    Co-authored-by: yanmingfu <yanmin...@baidu.com>
---
 .../org/apache/doris/binlog/BinlogManager.java     | 66 +++++++++++++---------
 .../org/apache/doris/persist/AlterViewInfo.java    |  4 ++
 .../java/org/apache/doris/persist/EditLog.java     |  7 ++-
 gensrc/thrift/FrontendService.thrift               |  4 +-
 4 files changed, 51 insertions(+), 30 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/binlog/BinlogManager.java 
b/fe/fe-core/src/main/java/org/apache/doris/binlog/BinlogManager.java
index ee89c14b40c..f07ead08648 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/binlog/BinlogManager.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/binlog/BinlogManager.java
@@ -25,6 +25,7 @@ import org.apache.doris.common.Pair;
 import org.apache.doris.common.proc.BaseProcResult;
 import org.apache.doris.common.proc.ProcResult;
 import org.apache.doris.persist.AlterDatabasePropertyInfo;
+import org.apache.doris.persist.AlterViewInfo;
 import org.apache.doris.persist.BarrierLog;
 import org.apache.doris.persist.BatchModifyPartitionsInfo;
 import org.apache.doris.persist.BinlogGcInfo;
@@ -322,6 +323,44 @@ public class BinlogManager {
         addBinlog(dbId, tableIds, commitSeq, timestamp, type, data, false, 
record);
     }
 
+    public void addTableRename(TableInfo info, long commitSeq) {
+        long dbId = info.getDbId();
+        long tableId = info.getTableId();
+        TBinlogType type = TBinlogType.RENAME_TABLE;
+        String data = info.toJson();
+        BarrierLog log = new BarrierLog(dbId, tableId, type, data);
+        addBarrierLog(log, commitSeq);
+    }
+
+    public void addColumnRename(TableRenameColumnInfo info, long commitSeq) {
+        long dbId = info.getDbId();
+        long tableId = info.getTableId();
+        TBinlogType type = TBinlogType.RENAME_COLUMN;
+        String data = info.toJson();
+        BarrierLog log = new BarrierLog(dbId, tableId, type, data);
+        addBarrierLog(log, commitSeq);
+    }
+
+    public void addModifyComment(ModifyCommentOperationLog info, long 
commitSeq) {
+        long dbId = info.getDbId();
+        long tableId = info.getTblId();
+        TBinlogType type = TBinlogType.MODIFY_COMMENT;
+        String data = info.toJson();
+        BarrierLog log = new BarrierLog(dbId, tableId, type, data);
+        addBarrierLog(log, commitSeq);
+    }
+
+    // add Modify view
+    public void addModifyViewDef(AlterViewInfo alterViewInfo, long commitSeq) {
+        long dbId = alterViewInfo.getDbId();
+        long tableId = alterViewInfo.getTableId();
+        TBinlogType type = TBinlogType.MODIFY_VIEW_DEF;
+        String data = alterViewInfo.toJson();
+        BarrierLog log = new BarrierLog(dbId, tableId, type, data);
+
+        addBarrierLog(log, commitSeq);
+    }
+
     // get binlog by dbId, return first binlog.version > version
     public Pair<TStatus, TBinlog> getBinlog(long dbId, long tableId, long 
prevCommitSeq) {
         TStatus status = new TStatus(TStatusCode.OK);
@@ -358,33 +397,6 @@ public class BinlogManager {
         }
     }
 
-    public void addTableRename(TableInfo info, long commitSeq) {
-        long dbId = info.getDbId();
-        long tableId = info.getTableId();
-        TBinlogType type = TBinlogType.RENAME_TABLE;
-        String data = info.toJson();
-        BarrierLog log = new BarrierLog(dbId, tableId, type, data);
-        addBarrierLog(log, commitSeq);
-    }
-
-    public void addColumnRename(TableRenameColumnInfo info, long commitSeq) {
-        long dbId = info.getDbId();
-        long tableId = info.getTableId();
-        TBinlogType type = TBinlogType.RENAME_COLUMN;
-        String data = info.toJson();
-        BarrierLog log = new BarrierLog(dbId, tableId, type, data);
-        addBarrierLog(log, commitSeq);
-    }
-
-    public void addModifyComment(ModifyCommentOperationLog info, long 
commitSeq) {
-        long dbId = info.getDbId();
-        long tableId = info.getTblId();
-        TBinlogType type = TBinlogType.MODIFY_COMMENT;
-        String data = info.toJson();
-        BarrierLog log = new BarrierLog(dbId, tableId, type, data);
-        addBarrierLog(log, commitSeq);
-    }
-
     // get the dropped partitions of the db.
     public List<Long> getDroppedPartitions(long dbId) {
         lock.readLock().lock();
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/persist/AlterViewInfo.java 
b/fe/fe-core/src/main/java/org/apache/doris/persist/AlterViewInfo.java
index df1fb5696c6..c54dfcf7c31 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/persist/AlterViewInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/persist/AlterViewInfo.java
@@ -105,4 +105,8 @@ public class AlterViewInfo implements Writable {
         String json = Text.readString(in);
         return GsonUtils.GSON.fromJson(json, AlterViewInfo.class);
     }
+
+    public String toJson() {
+        return GsonUtils.GSON.toJson(this);
+    }
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java 
b/fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java
index 7ad196178d6..3c16ba2f15a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java
@@ -308,6 +308,7 @@ public class EditLog {
                 case OperationType.OP_MODIFY_VIEW_DEF: {
                     AlterViewInfo info = (AlterViewInfo) journal.getData();
                     env.getAlterInstance().replayModifyViewDef(info);
+                    env.getBinlogManager().addModifyViewDef(info, logId);
                     break;
                 }
                 case OperationType.OP_RENAME_PARTITION: {
@@ -1530,7 +1531,11 @@ public class EditLog {
     }
 
     public void logModifyViewDef(AlterViewInfo alterViewInfo) {
-        logEdit(OperationType.OP_MODIFY_VIEW_DEF, alterViewInfo);
+        long logId = logEdit(OperationType.OP_MODIFY_VIEW_DEF, alterViewInfo);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("log modify view, logId : {}, infos: {}", logId, 
alterViewInfo);
+        }
+        Env.getCurrentEnv().getBinlogManager().addModifyViewDef(alterViewInfo, 
logId);
     }
 
     public void logRollupRename(TableInfo tableInfo) {
diff --git a/gensrc/thrift/FrontendService.thrift 
b/gensrc/thrift/FrontendService.thrift
index cdc5e70ad01..a36eb8e0de7 100644
--- a/gensrc/thrift/FrontendService.thrift
+++ b/gensrc/thrift/FrontendService.thrift
@@ -1140,6 +1140,7 @@ enum TBinlogType {
   RENAME_TABLE = 14,
   RENAME_COLUMN = 15,
   MODIFY_COMMENT = 16,
+  MODIFY_VIEW_DEF = 17,
 
   // Keep some IDs for allocation so that when new binlog types are added in 
the
   // future, the changes can be picked back to the old versions without 
breaking
@@ -1156,8 +1157,7 @@ enum TBinlogType {
   //    MODIFY_XXX = 17,
   //    MIN_UNKNOWN = 18,
   //    UNKNOWN_3 = 19,
-  MIN_UNKNOWN = 17,
-  UNKNOWN_2 = 18,
+  MIN_UNKNOWN = 18,
   UNKNOWN_3 = 19,
   UNKNOWN_4 = 20,
   UNKNOWN_5 = 21,


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

Reply via email to