Skip to content

Commit

Permalink
[feature](binlog) Wrap rename column binlog in BarrierLog
Browse files Browse the repository at this point in the history
Cherry-pick #39782
  • Loading branch information
w41ter committed Oct 31, 2024
1 parent 258a774 commit b600220
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.doris.persist.ReplacePartitionOperationLog;
import org.apache.doris.persist.TableAddOrDropColumnsInfo;
import org.apache.doris.persist.TableInfo;
import org.apache.doris.persist.TableRenameColumnInfo;
import org.apache.doris.persist.TruncateTableInfo;
import org.apache.doris.thrift.TBinlog;
import org.apache.doris.thrift.TBinlogType;
Expand Down Expand Up @@ -365,6 +366,15 @@ public void addTableRename(TableInfo info, long commitSeq) {
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);
}

// get the dropped partitions of the db.
public List<Long> getDroppedPartitions(long dbId) {
lock.readLock().lock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ public static void loadJournal(Env env, Long logId, JournalEntity journal) {
case OperationType.OP_RENAME_COLUMN: {
TableRenameColumnInfo info = (TableRenameColumnInfo) journal.getData();
env.replayRenameColumn(info);
Env.getCurrentEnv().getBinlogManager().addColumnRename(info, logId);
break;
}
case OperationType.OP_BACKUP_JOB: {
Expand Down Expand Up @@ -1454,7 +1455,9 @@ public void logPartitionRename(TableInfo tableInfo) {
}

public void logColumnRename(TableRenameColumnInfo info) {
logEdit(OperationType.OP_RENAME_COLUMN, info);
long logId = logEdit(OperationType.OP_RENAME_COLUMN, info);
LOG.info("log column rename, logId : {}, infos: {}", logId, info);
Env.getCurrentEnv().getBinlogManager().addColumnRename(info, logId);
}

public void logAddBroker(BrokerMgr.ModifyBrokerInfo info) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public Map<Long, Integer> getIndexIdToSchemaVersion() {
return indexIdToSchemaVersion;
}

public String toJson() {
return GsonUtils.GSON.toJson(this);
}

@Override
public void write(DataOutput out) throws IOException {
Text.writeString(out, GsonUtils.GSON.toJson(this));
Expand Down
1 change: 1 addition & 0 deletions gensrc/thrift/FrontendService.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,7 @@ enum TBinlogType {
REPLACE_PARTITIONS = 12,
TRUNCATE_TABLE = 13,
RENAME_TABLE = 14,
RENAME_COLUMN = 15,
}

struct TBinlog {
Expand Down

0 comments on commit b600220

Please sign in to comment.