Skip to content

Commit

Permalink
branch-3.0: [fix](restore) Release snapshots after the FINISHED state…
Browse files Browse the repository at this point in the history
… is persisted #47277 (#47285)

Cherry-picked from #47277

Co-authored-by: walter <[email protected]>
  • Loading branch information
github-actions[bot] and w41ter authored Jan 31, 2025
1 parent f552fe2 commit a365150
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -2101,8 +2101,8 @@ private Status allTabletCommitted(boolean isReplay) {
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();
Expand All @@ -2112,6 +2112,9 @@ private Status allTabletCommitted(boolean isReplay) {
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);
Expand Down Expand Up @@ -2179,7 +2182,7 @@ private void dropNonRestoredPartitions(
}
}

private void releaseSnapshots() {
private void releaseSnapshots(com.google.common.collect.Table<Long, Long, SnapshotInfo> snapshotInfos) {
if (snapshotInfos.isEmpty()) {
return;
}
Expand Down Expand Up @@ -2373,9 +2376,8 @@ private void cancelInternal(boolean isReplay) {
// 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();

Expand All @@ -2387,6 +2389,10 @@ private void cancelInternal(boolean isReplay) {

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;
}

Expand Down

0 comments on commit a365150

Please sign in to comment.