From 3cc505c12274f32c0607e7e606e157c5d2fcc939 Mon Sep 17 00:00:00 2001 From: smallx Date: Fri, 18 Oct 2024 11:28:16 +0800 Subject: [PATCH] [opt](binlog) Support modify comment binlog (#39783) Co-authored-by: walter --- .../java/org/apache/doris/binlog/BinlogManager.java | 10 ++++++++++ .../main/java/org/apache/doris/persist/EditLog.java | 4 +++- .../doris/persist/ModifyCommentOperationLog.java | 4 ++++ gensrc/thrift/FrontendService.thrift | 1 + 4 files changed, 18 insertions(+), 1 deletion(-) 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 47b0bb3c7670f5..4f67f663879875 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 @@ -29,6 +29,7 @@ import org.apache.doris.persist.BatchModifyPartitionsInfo; import org.apache.doris.persist.BinlogGcInfo; import org.apache.doris.persist.DropPartitionInfo; +import org.apache.doris.persist.ModifyCommentOperationLog; import org.apache.doris.persist.ModifyTablePropertyOperationLog; import org.apache.doris.persist.ReplacePartitionOperationLog; import org.apache.doris.persist.TableAddOrDropColumnsInfo; @@ -375,6 +376,15 @@ public void addColumnRename(TableRenameColumnInfo info, long commitSeq) { 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 getDroppedPartitions(long dbId) { lock.readLock().lock(); 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 963a1e06c8a6f6..7fdac2ebfaa8c5 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 @@ -1739,7 +1739,9 @@ public void logBatchRemoveTransactions(BatchRemoveTransactionsOperationV2 op) { } public void logModifyComment(ModifyCommentOperationLog op) { - logEdit(OperationType.OP_MODIFY_COMMENT, op); + long logId = logEdit(OperationType.OP_MODIFY_COMMENT, op); + LOG.info("log modify comment, logId : {}, infos: {}", logId, op); + Env.getCurrentEnv().getBinlogManager().addModifyComment(op, logId); } public void logCreateSqlBlockRule(SqlBlockRule rule) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/persist/ModifyCommentOperationLog.java b/fe/fe-core/src/main/java/org/apache/doris/persist/ModifyCommentOperationLog.java index 0b6f1f984507e0..f9bb7f5084e750 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/persist/ModifyCommentOperationLog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/persist/ModifyCommentOperationLog.java @@ -94,4 +94,8 @@ public static ModifyCommentOperationLog read(DataInput in) throws IOException { String json = Text.readString(in); return GsonUtils.GSON.fromJson(json, ModifyCommentOperationLog.class); } + + public String toJson() { + return GsonUtils.GSON.toJson(this); + } } diff --git a/gensrc/thrift/FrontendService.thrift b/gensrc/thrift/FrontendService.thrift index 575643030e11ca..2739b1c209607c 100644 --- a/gensrc/thrift/FrontendService.thrift +++ b/gensrc/thrift/FrontendService.thrift @@ -1029,6 +1029,7 @@ enum TBinlogType { TRUNCATE_TABLE = 13, RENAME_TABLE = 14, RENAME_COLUMN = 15, + MODIFY_COMMENT = 16, } struct TBinlog {