github-actions[bot] commented on code in PR #70142:
URL: https://github.com/apache/doris/pull/70142#discussion_r4480009612


##########
fe/fe-core/src/main/java/org/apache/doris/load/ExportMgr.java:
##########
@@ -246,8 +252,19 @@ public void checkCancelExportJobAuth(String ctlName, 
String dbName, List<ExportJ
 
     public void unprotectAddJob(ExportJob job) {
         exportIdToJob.put(job.getId(), job);
-        dbTolabelToExportJobId.computeIfAbsent(job.getDbId(),
-                k -> Maps.newHashMap()).put(job.getLabel(), job.getId());
+        unprotectRegisterLabel(job);
+    }
+
+    private void unprotectRegisterLabel(ExportJob job) {
+        Map<String, Long> labelToJobId = 
dbTolabelToExportJobId.computeIfAbsent(
+                job.getDbId(), k -> Maps.newHashMap());
+        Long currentJobId = labelToJobId.get(job.getLabel());
+        ExportJob currentJob = currentJobId == null ? null : 
exportIdToJob.get(currentJobId);
+        if (job.getState() == ExportJobState.CANCELLED
+                && currentJob != null && currentJob.getState() != 
ExportJobState.CANCELLED) {

Review Comment:
   [P2] Let newer replayed attempts replace stale finished label owners
   
   The master can remove FINISHED attempt A and reuse its label for B while a 
follower still retains A: for example, a normal `ADMIN SET FRONTEND CONFIG` 
lowers `history_job_keep_max_second` only on the master, leaving the follower 
at the seven-day default. `OP_EXPORT_CREATE` calls `cancelReplayedExportJob()` 
before registering B, so this guard rejects B's label mapping because A is 
FINISHED; replaying B's eventual CANCELLED state does the same. If that 
follower becomes master, retries of the cancelled label fail with 
`LabelAlreadyUsedException` until A expires under its longer local TTL, 
potentially days later. The previous registration replaced A with B. 
Distinguish an older cancelled history record from a genuinely later attempt 
admitted after cleanup, and cover that replay/failover sequence.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to