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

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 01894c8  [Bug] Fix bug that wrong usage for HashBasedTable iterator 
may cause ConcurrentModificationException (#4631)
01894c8 is described below

commit 01894c82fef86b3baf9108d58257922baeb7d97b
Author: caiconghui <55968745+caicong...@users.noreply.github.com>
AuthorDate: Sun Sep 20 20:58:08 2020 +0800

    [Bug] Fix bug that wrong usage for HashBasedTable iterator may cause 
ConcurrentModificationException (#4631)
    
    Fix bug that wrong usage for HashBasedTable iterator may cause 
ConcurrentModificationException
---
 .../java/org/apache/doris/clone/TabletChecker.java     | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/clone/TabletChecker.java 
b/fe/fe-core/src/main/java/org/apache/doris/clone/TabletChecker.java
index 952f564..e97eff8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/clone/TabletChecker.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/clone/TabletChecker.java
@@ -317,12 +317,12 @@ public class TabletChecker extends MasterDaemon {
     // 1. timeout
     // 2. meta not found
     private void removePriosIfNecessary() {
-        com.google.common.collect.Table<Long, Long, Set<PrioPart>> copiedPrio 
= null;
+        com.google.common.collect.Table<Long, Long, Set<PrioPart>> copiedPrios 
= null;
         synchronized (prios) {
-            copiedPrio = HashBasedTable.create(prios);
+            copiedPrios = HashBasedTable.create(prios);
         }
-
-        Iterator<Map.Entry<Long, Map<Long, Set<PrioPart>>>> iter = 
copiedPrio.rowMap().entrySet().iterator();
+        List<Pair<Long, Long>> deletedPrios = Lists.newArrayList();
+        Iterator<Map.Entry<Long, Map<Long, Set<PrioPart>>>> iter = 
copiedPrios.rowMap().entrySet().iterator();
         while (iter.hasNext()) {
             Map.Entry<Long, Map<Long, Set<PrioPart>>> dbEntry = iter.next();
             long dbId = dbEntry.getKey();
@@ -340,7 +340,7 @@ public class TabletChecker extends MasterDaemon {
                     long tblId = tblEntry.getKey();
                     OlapTable tbl = (OlapTable) db.getTable(tblId);
                     if (tbl == null) {
-                        jter.remove();
+                        deletedPrios.add(Pair.create(dbId, tblId));
                         continue;
                     }
 
@@ -348,7 +348,7 @@ public class TabletChecker extends MasterDaemon {
                     parts = parts.stream().filter(p -> 
(tbl.getPartition(p.partId) != null && !p.isTimeout())).collect(
                             Collectors.toSet());
                     if (parts.isEmpty()) {
-                        jter.remove();
+                        deletedPrios.add(Pair.create(dbId, tblId));
                     }
                 }
 
@@ -359,8 +359,10 @@ public class TabletChecker extends MasterDaemon {
                 db.readUnlock();
             }
         }
-
-        prios = copiedPrio;
+        for (Pair<Long, Long> prio : deletedPrios) {
+            copiedPrios.remove(prio.first, prio.second);
+        }
+        prios = copiedPrios;
     }
 
     /*


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to