caiconghui opened a new issue #4630: URL: https://github.com/apache/incubator-doris/issues/4630
**Describe the bug** In our production environment, we find that removePriosIfNecessary encounter exception like following: java.util.ConcurrentModificationException: null at java.util.HashMap$HashIterator.remove(HashMap.java:1507) ~[?:?] at com.google.common.collect.TransformedIterator.remove(TransformedIterator.java:53) ~[guava-15.0.jar:?] at org.apache.doris.clone.TabletChecker.removePriosIfNecessary(TabletChecker.java:356) ~[palo-fe.jar:?] at org.apache.doris.clone.TabletChecker.runAfterCatalogReady(TabletChecker.java:182) ~[palo-fe.jar:?] at org.apache.doris.common.util.MasterDaemon.runOneCycle(MasterDaemon.java:58) ~[palo-fe.jar:?] at org.apache.doris.common.util.Daemon.run(Daemon.java:116) [palo-fe.jar:?] this is because iterator will be invalid when hashtable iterator(iter or jter) invoke remove fuction more than once. **To Reproduce** I construct following case : ``` public class DemoTest { public static void main(String[] args) { com.google.common.collect.Table<Long, Long, Set<TabletChecker.PrioPart>> copiedPrios = HashBasedTable.create(); copiedPrios.put(1L, 1L, new HashSet<>()); copiedPrios.put(1L, 2L, new HashSet<>()); copiedPrios.put(2L, 2L, new HashSet<>()); // List<Pair<Long, Long>> prios = Lists.newArrayList(); Iterator<Map.Entry<Long, Map<Long, Set<TabletChecker.PrioPart>>>> iter = copiedPrios.rowMap().entrySet().iterator(); while (iter.hasNext()) { Map.Entry<Long, Map<Long, Set<TabletChecker.PrioPart>>> dbEntry = iter.next(); long dbId = dbEntry.getKey(); if (dbId % 2 == 0) { iter.remove(); continue; } Iterator<Map.Entry<Long, Set<TabletChecker.PrioPart>>> jter = dbEntry.getValue().entrySet().iterator(); while (jter.hasNext()) { Map.Entry<Long, Set<TabletChecker.PrioPart>> tblEntry = jter.next(); jter.remove(); // prios.add(Pair.create(dbId, tblEntry.getKey())); } } // for (Pair<Long, Long> prio : prios) { // copiedPrios.remove(prio.first, prio.second); // } System.out.println(copiedPrios.size()); } } ``` Steps to reproduce the behavior: run it and find that throw the following exception: Exception in thread "main" java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextNode(HashMap.java:1429) at java.util.HashMap$KeyIterator.next(HashMap.java:1453) at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48) at org.apache.doris.DemoTest.main(DemoTest.java:23) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) **Expected behavior** A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org