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

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 143dd4674d8 [fix](meta) fix ConcurrentModificationException when dump 
image (#28072) (#28401)
143dd4674d8 is described below

commit 143dd4674d85648f9d6a84b04f0032af8ae872eb
Author: Mingyu Chen <[email protected]>
AuthorDate: Fri Dec 15 18:24:17 2023 +0800

    [fix](meta) fix ConcurrentModificationException when dump image (#28072) 
(#28401)
    
    ```
    Caused by: java.util.ConcurrentModificationException
            at java.util.HashMap$HashIterator.nextNode(HashMap.java:1437) 
~[?:1.8.0_131]
            at java.util.HashMap$EntryIterator.next(HashMap.java:1471) 
~[?:1.8.0_131]
            at java.util.HashMap$EntryIterator.next(HashMap.java:1469) 
~[?:1.8.0_131]
            at 
org.apache.doris.catalog.CatalogRecycleBin.write(CatalogRecycleBin.java:1047) 
~[doris-fe.jar:1.2-SNAPSHOT]
            at org.apache.doris.catalog.Env.saveRecycleBin(Env.java:2298) 
~[doris-fe.jar:1.2-SNAPSHOT]
    ```
    
    When calling `/dump` api to dump image, ConcurrentModificationException may 
be thrown.
    Because no lock to protect `CatalogRecycleBin`
---
 .../src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java     | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java
index b28a7fd08d7..e83847a68ce 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java
@@ -1015,8 +1015,10 @@ public class CatalogRecycleBin extends MasterDaemon 
implements Writable {
         return Stream.of(dbInfos, tableInfos, 
partitionInfos).flatMap(Collection::stream).collect(Collectors.toList());
     }
 
+    // Need to add "synchronized", because when calling /dump api to dump 
image,
+    // this class is not protected by any lock, will throw 
ConcurrentModificationException.
     @Override
-    public void write(DataOutput out) throws IOException {
+    public synchronized void write(DataOutput out) throws IOException {
         int count = idToDatabase.size();
         out.writeInt(count);
         for (Map.Entry<Long, RecycleDatabaseInfo> entry : 
idToDatabase.entrySet()) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to