You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2023/01/28 02:23:21 UTC

[iotdb] 01/01: [To rel/1.0] [IOTDB-5431] Fix concurrent bug caused by using synchronizedSet() in DriverScheduler

This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a commit to branch IOTDB-5431-1.0
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit f45959e745dd98a473cc375450ccc95a8e083c13
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Sat Jan 28 10:23:03 2023 +0800

    [To rel/1.0] [IOTDB-5431] Fix concurrent bug caused by using synchronizedSet() in DriverScheduler
---
 .../db/mpp/execution/schedule/DriverScheduler.java | 23 ++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/execution/schedule/DriverScheduler.java b/server/src/main/java/org/apache/iotdb/db/mpp/execution/schedule/DriverScheduler.java
index dac98a07ee..680dc9ee6a 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/execution/schedule/DriverScheduler.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/execution/schedule/DriverScheduler.java
@@ -394,16 +394,19 @@ public class DriverScheduler implements IDriverScheduler, IService {
         QueryId queryId = task.getId().getQueryId();
         Set<DriverTask> queryRelatedTasks = queryMap.remove(queryId);
         if (queryRelatedTasks != null) {
-          for (DriverTask otherTask : queryRelatedTasks) {
-            if (task.equals(otherTask)) {
-              continue;
-            }
-            otherTask.lock();
-            try {
-              otherTask.setAbortCause(FragmentInstanceAbortedException.BY_QUERY_CASCADING_ABORTED);
-              clearDriverTask(otherTask);
-            } finally {
-              otherTask.unlock();
+          synchronized (queryRelatedTasks) {
+            for (DriverTask otherTask : queryRelatedTasks) {
+              if (task.equals(otherTask)) {
+                continue;
+              }
+              otherTask.lock();
+              try {
+                otherTask.setAbortCause(
+                    FragmentInstanceAbortedException.BY_QUERY_CASCADING_ABORTED);
+                clearDriverTask(otherTask);
+              } finally {
+                otherTask.unlock();
+              }
             }
           }
         }