Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Flaky Test] Throw an io.netty.util.IllegalReferenceCountException #2273

Open
3 tasks done
jerqi opened this issue Dec 4, 2024 · 6 comments
Open
3 tasks done

[Flaky Test] Throw an io.netty.util.IllegalReferenceCountException #2273

jerqi opened this issue Dec 4, 2024 · 6 comments

Comments

@jerqi
Copy link
Contributor

jerqi commented Dec 4, 2024

Code of Conduct

Search before asking

  • I have searched in the issues and found no similar issues.

Describe the flaky test

Caused by: io.netty.util.IllegalReferenceCountException: refCnt: 0
at io.netty.buffer.AbstractByteBuf.ensureAccessible(AbstractByteBuf.java:1454)
at io.netty.buffer.AbstractByteBuf.checkIndex(AbstractByteBuf.java:1383)
at io.netty.buffer.PooledByteBuf.duplicateInternalNioBuffer(PooledByteBuf.java:196)
at io.netty.buffer.PooledByteBuf.nioBuffer(PooledByteBuf.java:213)
at io.netty.buffer.AbstractByteBuf.nioBuffer(AbstractByteBuf.java:1231)
at org.apache.uniffle.common.netty.buffer.NettyManagedBuffer.nioByteBuffer(NettyManagedBuffer.java:48)
at org.apache.uniffle.common.ShuffleIndexResult.getIndexData(ShuffleIndexResult.java:84)

Actions URL

https://github.com/apache/incubator-uniffle/actions/runs/12158115239/attempts/1

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
@jerqi
Copy link
Contributor Author

jerqi commented Dec 4, 2024

Maybe we shouldn't use PooledByteBuf. Because we will release the memory after we used the memory. You can see

cc @maobaolong @advancedxy @rickyma @LuciferYang WDYT?

@rickyma
Copy link
Contributor

rickyma commented Dec 5, 2024

Users can choose whatever kind of bytebuf they want:
client: #1767
server: #2145

We basically will release every bytebuf, but it does not mean that we don't need PooledByteBuf.
We use PooledByteBuf to reduce the number of interactions with the operating system for memory allocation and deallocation. This helps to avoid potential issues such as abnormal growth of RSS (Resident Set Size) memory, which might occur due to frequent and inefficient memory management (especially when using glibc, that's why we recommend using mimalloc).

@jerqi
Copy link
Contributor Author

jerqi commented Dec 5, 2024

Users can choose whatever kind of bytebuf they want: client: #1767 server: #2145

We basically will release every bytebuf, but it does not mean that we don't need PooledByteBuf. We use PooledByteBuf to reduce the number of interactions with the operating system for memory allocation and deallocation. This helps to avoid potential issues such as abnormal growth of RSS (Resident Set Size) memory, which might occur due to frequent and inefficient memory management (especially when using glibc, that's why we recommend using mimalloc).

But it will throw a ref count exception in our UT. I suspect that we released a reused bytebuf in the ByteBuf pool.

@rickyma
Copy link
Contributor

rickyma commented Dec 5, 2024

I didn't look into the code carefully. I suppose this should be a bug. @maobaolong

Similar to #1628?

@jerqi
Copy link
Contributor Author

jerqi commented Dec 5, 2024

I didn't look into the code carefully. I suppose this should be a bug. @maobaolong

Similar to #1628?

Yes, they are similar.

@jerqi
Copy link
Contributor Author

jerqi commented Dec 5, 2024

I suspect that the issue is caused by TransportFrameDecoder

  @Override
  public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
    // Release all buffers that are still in our ownership.
    // Doing this in handlerRemoved(...) guarantees that this will happen in all cases:
    //     - When the Channel becomes inactive
    //     - When the decoder is removed from the ChannelPipeline
    for (ByteBuf b : buffers) {
      b.release();
    }
    buffers.clear();
    headerBuf.release();
    super.handlerRemoved(ctx);
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants