Skip to content

Bugfix: Socket without health check was abnormally recycled#3010

Merged
wwbmmm merged 1 commit into
apache:masterfrom
chenBright:fix_socket_hc_disable
Jun 29, 2025
Merged

Bugfix: Socket without health check was abnormally recycled#3010
wwbmmm merged 1 commit into
apache:masterfrom
chenBright:fix_socket_hc_disable

Conversation

@chenBright

Copy link
Copy Markdown
Contributor

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:

@chenBright chenBright requested a review from Copilot June 28, 2025 09:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that sockets remain referenced in the SocketMap even when health checks are disabled, preventing premature recycling.

  • Introduce ReleaseReference to unify ref‐release logic for both HC‐enabled and HC‐disabled sockets
  • Update Insert/RemoveInternal in SocketMap to 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

Comment thread src/brpc/selective_channel.cpp Outdated
Comment thread test/brpc_socket_map_unittest.cpp Outdated
@chenBright chenBright force-pushed the fix_socket_hc_disable branch from 7e92952 to 1f61bd2 Compare June 28, 2025 09:22
@chenBright chenBright force-pushed the fix_socket_hc_disable branch from 1f61bd2 to fbc508d Compare June 28, 2025 09:52
@wwbmmm wwbmmm merged commit 5bc6da6 into apache:master Jun 29, 2025
26 of 27 checks passed
@chenBright chenBright deleted the fix_socket_hc_disable branch June 29, 2025 12:48
chenBright added a commit to chenBright/brpc that referenced this pull request Jul 6, 2025
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.

未开启健康检查时客户端偶发崩溃且易现一直超时

3 participants