Skip to content

Commit

Permalink
branch-3.0: [fix](schema-change) Fix job replay failure when partitio…
Browse files Browse the repository at this point in the history
…ns added to table after job finish apache#46166 (apache#46247)

Cherry-picked from apache#46166

Co-authored-by: Siyang Tang <[email protected]>
  • Loading branch information
github-actions[bot] and TangSiyang2001 authored Jan 2, 2025
1 parent ca9053f commit a6c0652
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -652,21 +652,21 @@ protected void runRunningJob() throws AlterCancelException {
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);
Expand Down

0 comments on commit a6c0652

Please sign in to comment.