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 34c3b3962cf [fix](restore) Release snapshots after the FINISHED state is persisted (#47277) 34c3b3962cf is described below commit 34c3b3962cfaa847a89696db3c4615d2043dfca3 Author: walter <maoch...@selectdb.com> AuthorDate: Tue Jan 21 19:52:29 2025 +0800 [fix](restore) Release snapshots after the FINISHED state is persisted (#47277) When Doris FE restarts, the DirMoveTask will be sent to BE again. If the ReleaseSnapshotTask is sent to BE before the FINISHED state is persisted, and Doris FE restarts, then the DirMoveTask and the restore job will fail too. --- .../main/java/org/apache/doris/backup/RestoreJob.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java b/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java index 746001a6a43..e563192c584 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java +++ b/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java @@ -2124,8 +2124,8 @@ public class RestoreJob extends AbstractJob implements GsonPostProcessable { restoredTbls.clear(); restoredResources.clear(); - // release snapshot before clearing snapshotInfos - releaseSnapshots(); + com.google.common.collect.Table<Long, Long, SnapshotInfo> savedSnapshotInfos = snapshotInfos; + snapshotInfos = HashBasedTable.create(); snapshotInfos.clear(); fileMapping.clear(); @@ -2135,6 +2135,9 @@ public class RestoreJob extends AbstractJob implements GsonPostProcessable { state = RestoreJobState.FINISHED; env.getEditLog().logRestoreJob(this); + + // Only send release snapshot tasks after the job is finished. + releaseSnapshots(savedSnapshotInfos); } LOG.info("job is finished. is replay: {}. {}", isReplay, this); @@ -2202,7 +2205,7 @@ public class RestoreJob extends AbstractJob implements GsonPostProcessable { } } - private void releaseSnapshots() { + private void releaseSnapshots(com.google.common.collect.Table<Long, Long, SnapshotInfo> snapshotInfos) { if (snapshotInfos.isEmpty()) { return; } @@ -2396,9 +2399,8 @@ public class RestoreJob extends AbstractJob implements GsonPostProcessable { // backupMeta is useless backupMeta = null; - releaseSnapshots(); - - snapshotInfos.clear(); + com.google.common.collect.Table<Long, Long, SnapshotInfo> savedSnapshotInfos = snapshotInfos; + snapshotInfos = HashBasedTable.create(); fileMapping.clear(); jobInfo.releaseSnapshotInfo(); @@ -2415,6 +2417,10 @@ public class RestoreJob extends AbstractJob implements GsonPostProcessable { LOG.info("finished to cancel restore job. current state: {}. is replay: {}. {}", curState.name(), isReplay, this); + + // Send release snapshot tasks after log restore job, so that the snapshot won't be released + // before the cancelled restore job is persisted. + releaseSnapshots(savedSnapshotInfos); return; } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org