branch-2.1: [fix](binlog) Record rollup index info for alterJob binlog #50850, #50337 (#50874)

cherry pick from #50850, #50337

---------

Co-authored-by: Uniqueyou <wangyixuan@selectdb.com>
This commit is contained in:
walter
2025-05-17 16:19:57 +08:00
committed by GitHub
parent 505c9af95a
commit 35af34f1ce
2 changed files with 33 additions and 0 deletions

View File

@ -183,6 +183,22 @@ public class RollupJobV2 extends AlterJobV2 implements GsonPostProcessable {
this.storageFormat = storageFormat;
}
public long getRollupIndexId() {
return rollupIndexId;
}
public String getRollupIndexName() {
return rollupIndexName;
}
public long getBaseIndexId() {
return baseIndexId;
}
public String getBaseIndexName() {
return baseIndexName;
}
private void initAnalyzer() throws AnalysisException {
ConnectContext connectContext = new ConnectContext();
Database db;

View File

@ -18,6 +18,7 @@
package org.apache.doris.binlog;
import org.apache.doris.alter.AlterJobV2;
import org.apache.doris.alter.RollupJobV2;
import org.apache.doris.alter.SchemaChangeJobV2;
import org.apache.doris.persist.gson.GsonUtils;
@ -42,8 +43,18 @@ public class AlterJobRecord {
private AlterJobV2.JobState jobState;
@SerializedName(value = "rawSql")
private String rawSql;
// for schema change
@SerializedName(value = "iim")
private Map<Long, Long> indexIdMap;
// for rollup
@SerializedName(value = "rollupIndexId")
private long rollupIndexId;
@SerializedName(value = "rollUpIndexName")
private String rollUpIndexName;
@SerializedName(value = "baseIndexId")
private long baseIndexId;
@SerializedName(value = "baseIndexName")
private String baseIndexName;
public AlterJobRecord(AlterJobV2 job) {
this.type = job.getType();
@ -55,6 +66,12 @@ public class AlterJobRecord {
this.rawSql = job.getRawSql();
if (type == AlterJobV2.JobType.SCHEMA_CHANGE && job instanceof SchemaChangeJobV2) {
this.indexIdMap = ((SchemaChangeJobV2) job).getIndexIdMap();
} else if (type == AlterJobV2.JobType.ROLLUP && job instanceof RollupJobV2) {
RollupJobV2 rollupJob = (RollupJobV2) job;
this.rollupIndexId = rollupJob.getRollupIndexId();
this.rollUpIndexName = rollupJob.getRollupIndexName();
this.baseIndexId = rollupJob.getBaseIndexId();
this.baseIndexName = rollupJob.getBaseIndexName();
}
}