Skip to content

Commit 753696f

Browse files
mergify[bot]srlch
andauthored
[BugFix] Fix miss update job state when replaying restore log may cause restored table lost after FE restart (backport #59056) (backport #68396) (#68412)
Signed-off-by: srlch <111035020+srlch@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: srlch <111035020+srlch@users.noreply.github.com>
1 parent 6b8342a commit 753696f

2 files changed

Lines changed: 28 additions & 5 deletions

File tree

fe/fe-core/src/main/java/com/starrocks/backup/BackupHandler.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -641,10 +641,6 @@ public void replayAddJob(AbstractJob job) {
641641
// for example: In restore job, PENDING will transfer to SNAPSHOTING, not DOWNLOAD.
642642
job.replayRun();
643643
}
644-
if (isJobExpired(job, System.currentTimeMillis())) {
645-
LOG.warn("skip expired job {}", job);
646-
return;
647-
}
648644
dbIdToBackupOrRestoreJob.put(job.getDbId(), job);
649645
mvRestoreContext.addIntoMvBaseTableBackupInfo(job);
650646
}

fe/fe-core/src/test/java/com/starrocks/backup/RestoreJobTest.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,4 +927,31 @@ public synchronized QueryStatement init() throws UserException {
927927
Assert.assertEquals(Status.OK, job.getStatus());
928928
Assert.assertEquals(RestoreJobState.FINISHED, job.getState());
929929
}
930-
}
930+
931+
@Test
932+
public void testReplayAddExpiredJob() {
933+
RestoreJob job1 = new RestoreJob(label, "2018-01-01 01:01:01", db.getId() + 999, db.getFullName() + "xxx",
934+
new BackupJobInfo(), false, 3, 100000,
935+
globalStateMgr, repo.getId(), backupMeta, new MvRestoreContext());
936+
937+
BackupJobInfo jobInfo = new BackupJobInfo();
938+
BackupTableInfo tblInfo = new BackupTableInfo();
939+
tblInfo.id = CatalogMocker.TEST_TBL2_ID;
940+
tblInfo.name = CatalogMocker.TEST_TBL2_NAME;
941+
jobInfo.tables.put(tblInfo.name, tblInfo);
942+
RestoreJob job3 = new RestoreJob(label, "2018-01-01 01:01:01", db.getId() + 999, db.getFullName() + "xxx",
943+
jobInfo, false, 3, 100000,
944+
globalStateMgr, repo.getId(), backupMeta, new MvRestoreContext());
945+
946+
BackupHandler localBackupHandler = new BackupHandler();
947+
job1.setState(RestoreJob.RestoreJobState.PENDING);
948+
localBackupHandler.replayAddJob(job1);
949+
Assert.assertTrue(localBackupHandler.getJob(db.getId() + 999).isPending());
950+
int oldVal = Config.history_job_keep_max_second;
951+
Config.history_job_keep_max_second = 0;
952+
job3.setState(RestoreJob.RestoreJobState.FINISHED);
953+
localBackupHandler.replayAddJob(job3);
954+
Config.history_job_keep_max_second = oldVal;
955+
Assert.assertTrue(localBackupHandler.getJob(db.getId() + 999).isDone());
956+
}
957+
}

0 commit comments

Comments
 (0)