Skip to content

Reproduce Channel Capacity Leak Under Load #332

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

Closed
wants to merge 1 commit into from

Conversation

imz87
Copy link

@imz87 imz87 commented May 27, 2025

This PR introduces three test cases that reproduce a bug where channel capacity is not reduced as expected after a flood of messages are sent from the server to the client.

What’s the bug
Under multi-threaded server configurations, the server appears to send messages successfully, but the internal channel capacity is not correctly decremented or released. This results in:

Potential channel memory leaks
Inaccurate flow control behavior
Misleading metrics related to capacity usage

@zekronium

@imz87
Copy link
Author

imz87 commented May 27, 2025

Hi @normanmaurer ,

I've added a few tests that reproduce a potential bug where the channel capacity isn't reduced correctly after sending many messages. The issue appears in multi-threaded server setups.

Let me know what you think, or if you'd like me to adjust anything!

tnx

@imz87
Copy link
Author

imz87 commented May 28, 2025

I've added three tests.

    1. testSingleThreadedChannelCapacityLeakWhenSendingManyMessages
    2. testMultiThreadedChannelCapacityLeakWhenSendingManyMessages
    3. testScheduledTaskChannelCapacityLeakWhenSendingManyMessages

The testSingleThreadedChannelCapacityLeakWhenSendingManyMessages test works correctly, but both testMultiThreadedChannelCapacityLeakWhenSendingManyMessages and testScheduledTaskChannelCapacityLeakWhenSendingManyMessages are failing. the last two are similar to each other.

@normanmaurer

@normanmaurer
Copy link
Member

@imz87 I think this is just a matter of how the tests are written an behave. So for the first test testSingleThreadedChannelCapacityLeakWhenSendingManyMessages you basically run a while loop in the event loop and so at at some point too much data will be buffered without be able to actually flush it on the transport itself. Because of this you will see the writability change. With both of the others you will not cause the event loop to "block" and so the writes will happen fast enough to not cause any writability changes. Beside this calling ((DuplexChannel) ctx.channel()).shutdownOutput(); after you called serverBulkMessageSender.handle(ctx); will only correctly work for the testSingleThreadedChannelCapacityLeakWhenSendingManyMessages(...) as this will only happen once the writability event was observed. For both of the others it will directly happen as you don't have a while loop that will "block" the event loop. So imho everything is working as expected.

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

Successfully merging this pull request may close these issues.

2 participants