This is an automated email from the ASF dual-hosted git repository. gavinchou pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 04d792771e1 [fix](schema-change) Fix job replay failure when partitions added to table after job finish (#46166) 04d792771e1 is described below commit 04d792771e11bc662ed8435446fceb97ecf3c7b0 Author: Siyang Tang <tangsiy...@selectdb.com> AuthorDate: Thu Jan 2 10:19:24 2025 +0800 [fix](schema-change) Fix job replay failure when partitions added to table after job finish (#46166) If all partitions in table are engaged in schema change job replay, replay may fail if there is any partition created after alter job commitment and before job replay. Therefore, write edit log within table write lock. --- .../org/apache/doris/alter/SchemaChangeJobV2.java | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeJobV2.java b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeJobV2.java index a624dc3c733..54bcc352627 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeJobV2.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeJobV2.java @@ -663,21 +663,21 @@ public class SchemaChangeJobV2 extends AlterJobV2 { commitShadowIndex(); // all partitions are good onFinished(tbl); - } finally { - tbl.writeUnlock(); - } - - pruneMeta(); - - LOG.info("schema change job finished: {}", jobId); + pruneMeta(); - changeTableState(dbId, tableId, OlapTableState.NORMAL); - LOG.info("set table's state to NORMAL, table id: {}, job id: {}", tableId, jobId); + LOG.info("schema change job finished: {}", jobId); - this.jobState = JobState.FINISHED; - this.finishedTimeMs = System.currentTimeMillis(); - Env.getCurrentEnv().getEditLog().logAlterJob(this); + changeTableState(dbId, tableId, OlapTableState.NORMAL); + LOG.info("set table's state to NORMAL, table id: {}, job id: {}", tableId, jobId); + this.jobState = JobState.FINISHED; + this.finishedTimeMs = System.currentTimeMillis(); + // Write edit log with table's write lock held, to avoid adding partitions before writing edit log, + // else it will try to transform index in newly added partition while replaying and result in failure. + Env.getCurrentEnv().getEditLog().logAlterJob(this); + } finally { + tbl.writeUnlock(); + } postProcessOriginIndex(); // Drop table column stats after schema change finished. Env.getCurrentEnv().getAnalysisManager().dropStats(tbl, null); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org