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

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


The following commit(s) were added to refs/heads/master by this push:
     new 4c14b977d [#1628] test(client): Fix double release ShuffleIndexResult 
cause exception to pass flaky test  (#2179)
4c14b977d is described below

commit 4c14b977def9d8f56a702ae54ee4881c5abd2cb3
Author: maobaolong <[email protected]>
AuthorDate: Fri Oct 18 11:23:57 2024 +0800

    [#1628] test(client): Fix double release ShuffleIndexResult cause exception 
to pass flaky test  (#2179)
    
    ### What changes were proposed in this pull request?
    
    (Please outline the changes and how this PR fixes the issue.)
    
    ### Why are the changes needed?
    
    - Pass the flaky test
    - Avoid memory leak after double release the `ShuffleIndexResult`
    
    Fix: #1628
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Flaky test can be fixed.
---
 .../org/apache/uniffle/common/ShuffleIndexResult.java    | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git 
a/common/src/main/java/org/apache/uniffle/common/ShuffleIndexResult.java 
b/common/src/main/java/org/apache/uniffle/common/ShuffleIndexResult.java
index c90f8997e..d4f863f89 100644
--- a/common/src/main/java/org/apache/uniffle/common/ShuffleIndexResult.java
+++ b/common/src/main/java/org/apache/uniffle/common/ShuffleIndexResult.java
@@ -20,12 +20,17 @@ package org.apache.uniffle.common;
 import java.nio.ByteBuffer;
 
 import io.netty.buffer.Unpooled;
+import io.netty.util.IllegalReferenceCountException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.uniffle.common.netty.buffer.ManagedBuffer;
 import org.apache.uniffle.common.netty.buffer.NettyManagedBuffer;
 import org.apache.uniffle.common.util.ByteBufUtils;
 
 public class ShuffleIndexResult {
+  private static final Logger LOG = 
LoggerFactory.getLogger(ShuffleIndexResult.class);
+
   private final ManagedBuffer buffer;
   private long dataFileLen;
   private String dataFileName;
@@ -74,7 +79,16 @@ public class ShuffleIndexResult {
 
   public void release() {
     if (this.buffer != null) {
-      this.buffer.release();
+      try {
+        this.buffer.release();
+      } catch (IllegalReferenceCountException e) {
+        LOG.warn(
+            "Failed to release shuffle index result with length {} of {}. "
+                + "Maybe it has been released by others.",
+            dataFileLen,
+            dataFileName,
+            e);
+      }
     }
   }
 

Reply via email to