Skip to content

Conversation

acogoluegnes
Copy link
Contributor

The broker can close a connection abruptly (in case of re-authentication fails) and the application can call Client#close() at the same time. There can be a race condition whereby the call to close() triggers a regular closing initiated by the client but the Netty channel is already inactive. The call to close() then blocks until it reaches the RPC timeout.

This commit makes sure the channel is still active before trying to send the close command to the broker.

The broker can close a connection abruptly (in case of re-authentication
fails) and the application can call Client#close() at the same time.
There can be a race condition whereby the call to close() triggers a
regular closing initiated by the client but the Netty channel is already
inactive. The call to close() then blocks until it reaches the RPC
timeout.

This commit makes sure the channel is still active before trying to send
the close command to the broker.
@acogoluegnes acogoluegnes added this to the 1.3.0 milestone Aug 20, 2025
@acogoluegnes acogoluegnes added the bug Something isn't working label Aug 20, 2025
@acogoluegnes acogoluegnes merged commit ca55e27 into main Aug 20, 2025
3 checks passed
@acogoluegnes acogoluegnes deleted the race-condition-closing branch August 20, 2025 10:14
github-actions bot pushed a commit that referenced this pull request Aug 20, 2025
Fix race condition on connection closing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant