Bugfix: Socket without health check was abnormally recycled#3010
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR ensures that sockets remain referenced in the SocketMap even when health checks are disabled, preventing premature recycling.
- Introduce
ReleaseReferenceto unify ref‐release logic for both HC‐enabled and HC‐disabled sockets - Update
Insert/RemoveInternalinSocketMapto use the new release helper - Modify channel balancer to explicitly fail when HC is disabled and add a unit test for the disable‐HC case
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/brpc_socket_map_unittest.cpp | Added a disable_health_check test to cover the new path |
| src/brpc/socket_map.h | Declared private ReleaseReference helper |
| src/brpc/socket_map.cpp | Replaced raw HC‐release calls with ReleaseReference |
| src/brpc/selective_channel.cpp | Split error checks and updated HC‐disabled fatal message |
7e92952 to
1f61bd2
Compare
1f61bd2 to
fbc508d
Compare
chenBright
added a commit
to chenBright/brpc
that referenced
this pull request
Jul 6, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: resolve #2998
Problem Summary:
When the health check is turned off, the SocketMap does not hold a reference to the Socket, so the Socket will be abnormally recycled when the connection is closed.
What is changed and the side effects?
Changed:
Regardless of whether the health check is enabled, SocketMap must hold a reference to the socket.
Side effects:
Performance effects:
Breaking backward compatibility:
Check List: