From 5d345144e42db1859d77e047fab5cfb962c96a48 Mon Sep 17 00:00:00 2001 From: guowl3 <70270140+guowl3@users.noreply.github.com> Date: Wed, 15 Nov 2023 11:06:55 +0800 Subject: [PATCH] fix(dlm): data delete failed after data archived. (#735) Regenerate the ID for the rollback task and delete task to avoid task failure due to duplicate IDs --- .../odc/service/schedule/job/DataArchiveDeleteJob.java | 4 ++++ .../odc/service/schedule/job/DataArchiveRollbackJob.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/server/odc-service/src/main/java/com/oceanbase/odc/service/schedule/job/DataArchiveDeleteJob.java b/server/odc-service/src/main/java/com/oceanbase/odc/service/schedule/job/DataArchiveDeleteJob.java index b3a949675a..e104e88290 100644 --- a/server/odc-service/src/main/java/com/oceanbase/odc/service/schedule/job/DataArchiveDeleteJob.java +++ b/server/odc-service/src/main/java/com/oceanbase/odc/service/schedule/job/DataArchiveDeleteJob.java @@ -25,6 +25,7 @@ import com.oceanbase.odc.core.shared.constant.TaskStatus; import com.oceanbase.odc.metadb.schedule.ScheduleTaskEntity; import com.oceanbase.odc.service.dlm.model.DlmTask; +import com.oceanbase.odc.service.dlm.utils.DlmJobIdUtil; import com.oceanbase.odc.service.schedule.model.DataArchiveClearParameters; import com.oceanbase.tools.migrator.common.enums.JobType; @@ -68,6 +69,9 @@ public void execute(JobExecutionContext context) { List taskUnits = JsonUtils.fromJson(dataArchiveTask.getResultJson(), new TypeReference>() {}); taskUnits.forEach(taskUnit -> { + taskUnit.setId(DlmJobIdUtil.generateHistoryJobId(taskEntity.getJobName(), taskEntity.getJobGroup(), + taskEntity.getId(), + taskUnits.size())); taskUnit.setJobType(JobType.DELETE); taskUnit.setStatus(TaskStatus.PREPARING); }); diff --git a/server/odc-service/src/main/java/com/oceanbase/odc/service/schedule/job/DataArchiveRollbackJob.java b/server/odc-service/src/main/java/com/oceanbase/odc/service/schedule/job/DataArchiveRollbackJob.java index a2da96e85c..ec319c4ea2 100644 --- a/server/odc-service/src/main/java/com/oceanbase/odc/service/schedule/job/DataArchiveRollbackJob.java +++ b/server/odc-service/src/main/java/com/oceanbase/odc/service/schedule/job/DataArchiveRollbackJob.java @@ -25,6 +25,7 @@ import com.oceanbase.odc.core.shared.constant.TaskStatus; import com.oceanbase.odc.metadb.schedule.ScheduleTaskEntity; import com.oceanbase.odc.service.dlm.model.DlmTask; +import com.oceanbase.odc.service.dlm.utils.DlmJobIdUtil; import com.oceanbase.odc.service.schedule.model.DataArchiveRollbackParameters; import com.oceanbase.tools.migrator.common.enums.JobType; @@ -65,6 +66,9 @@ public void execute(JobExecutionContext context) { new TypeReference>() {}); taskUnits.forEach(taskUnit -> { Long temp = taskUnit.getSourceDatabaseId(); + taskUnit.setId(DlmJobIdUtil.generateHistoryJobId(taskEntity.getJobName(), taskEntity.getJobGroup(), + taskEntity.getId(), + taskUnits.size())); taskUnit.setSourceDatabaseId(taskUnit.getTargetDatabaseId()); taskUnit.setTargetDatabaseId(temp); taskUnit.setJobType(JobType.ROLLBACK);