Skip to content

Commit

Permalink
[#1628] test(client): Fix double release ShuffleIndexResult cause exc…
Browse files Browse the repository at this point in the history
…eption 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.
  • Loading branch information
maobaolong authored Oct 18, 2024
1 parent 5f8d6de commit 4c14b97
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@
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;
Expand Down Expand Up @@ -74,7 +79,16 @@ public boolean isEmpty() {

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);
}
}
}

Expand Down

0 comments on commit 4c14b97

Please sign in to comment.