From 834eb77bdf9cf96ba9dc0e4e19ef1c076be43ee5 Mon Sep 17 00:00:00 2001 From: Calvin Kirs Date: Thu, 22 Feb 2024 10:57:34 +0800 Subject: [PATCH] [Fix](Job)TVF Query JOB Concurrent Reading and Writing Causes Exception --- .../main/java/org/apache/doris/job/base/AbstractJob.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/job/base/AbstractJob.java b/fe/fe-core/src/main/java/org/apache/doris/job/base/AbstractJob.java index 78d7598bf135a5..8c1d6da3a63565 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/job/base/AbstractJob.java +++ b/fe/fe-core/src/main/java/org/apache/doris/job/base/AbstractJob.java @@ -50,6 +50,7 @@ import java.util.Comparator; import java.util.List; import java.util.Set; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.stream.Collectors; @@ -128,7 +129,7 @@ public AbstractJob(Long jobId, String jobName, JobStatus jobStatus, this.executeSql = executeSql; } - private List runningTasks = new ArrayList<>(); + private CopyOnWriteArrayList runningTasks = new CopyOnWriteArrayList<>(); private Lock createTaskLock = new ReentrantLock(); @@ -140,7 +141,7 @@ public void cancelAllTasks() throws JobException { for (T task : runningTasks) { task.cancel(); } - runningTasks = new ArrayList<>(); + runningTasks = new CopyOnWriteArrayList<>(); } private static final ImmutableList TITLE_NAMES = @@ -270,7 +271,7 @@ public void updateJobStatus(JobStatus newJobStatus) throws JobException { public static AbstractJob readFields(DataInput in) throws IOException { String jsonJob = Text.readString(in); AbstractJob job = GsonUtils.GSON.fromJson(jsonJob, AbstractJob.class); - job.runningTasks = new ArrayList<>(); + job.runningTasks = new CopyOnWriteArrayList(); job.createTaskLock = new ReentrantLock(); return job; }