diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/ExportMgr.java b/fe/fe-core/src/main/java/org/apache/doris/load/ExportMgr.java index 238b40a7d41679..b798c053186ce5 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/load/ExportMgr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/load/ExportMgr.java @@ -120,8 +120,16 @@ public void addExportJobAndRegisterTask(ExportJob job) throws Exception { job.getBrokerDesc()); } // ATTN: Must add task after edit log, otherwise the job may finish before adding job. - for (int i = 0; i < job.getCopiedTaskExecutors().size(); i++) { - Env.getCurrentEnv().getTransientTaskManager().addMemoryTask(job.getCopiedTaskExecutors().get(i)); + try { + for (int i = 0; i < job.getCopiedTaskExecutors().size(); i++) { + Env.getCurrentEnv().getTransientTaskManager().addMemoryTask(job.getCopiedTaskExecutors().get(i)); + } + } catch (Exception e) { + // If there happens exceptions in `addMemoryTask` + // we must update the state of export job to `CANCELLED` + // because we have added this export in `ExportMgr` + job.updateExportJobState(ExportJobState.CANCELLED, 0L, null, + ExportFailMsg.CancelType.RUN_FAIL, e.getMessage()); } LOG.info("add export job. {}", job); }