Skip to content

fix polaris.discovery.heartbeat.enabled is not effective #1565 #1621

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

Open
wants to merge 13 commits into
base: 2022
Choose a base branch
from

Conversation

zihenzzz
Copy link

@zihenzzz zihenzzz commented Jun 17, 2025

PR Type

Bugfix.

Describe what this PR does for and how you did.

This PR fixes the issue where polaris.discovery.heartbeat.enabled=false configuration is not effective. When heartbeat is disabled, the instance heartbeat tasks were still running and producing logs like:

We found that even if Heartbeat. enabled=false is set, [SyncHeartbeat] related logs still appear in the logs. The erroneous logic of Polaris Service Registry resulted in Heartbeat mechanism erroneously relying on healthCheckURL instead of the correct configuration item HeartbeatEnabled. The original intention of healthCheckURL is to provide an HTTP interface for health checks (such as/health), used by external systems (such as Polaris console) to detect service status, rather than controlling heartbeat

The heartbeat thread that was forcibly enabled through heartleatExecutor. scheduleWithFixedDelay() in the original code has been completely removed and replaced with a built-in heartbeat mechanism that relies on the registering Instance() method of the Polaris SDK.
The original version used StringUtils.isBlank (healthCheckURL) as the judgment condition → error logic. The new version directly uses HeartbeatEnabled configuration → correct logic.

Note

This fix works across all Spring Cloud versions (Hoxton, 2022, and 2023) and all operating systems. No breaking changes to existing functionality when heartbeat is enabled.

Checklist

  • Add information of this PR to CHANGELOG.md in root of project.
  • Add documentation in javadoc or comment below the PR if necessary.

@zihenzzz zihenzzz changed the title fix fix $1565 Jun 17, 2025
@zihenzzz zihenzzz changed the title fix $1565 fix #1565 Jun 17, 2025
Copy link
Collaborator

@SkyeBeFreeman SkyeBeFreeman left a comment

Choose a reason for hiding this comment

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

Add this PR information to CHANGELOG.md in the root dir.

@SkyeBeFreeman SkyeBeFreeman linked an issue Jun 17, 2025 that may be closed by this pull request
@zihenzzz
Copy link
Author

If there is any problem, please let me know and I will correct it as soon as possible.

@SkyeBeFreeman
Copy link
Collaborator

@zihenz If the heartbeat is disabled and polarisDiscoveryProperties.getHealthCheckUrl() is null, the heartbeat report will still be performed. You can try this.

@zihenzzz
Copy link
Author

If there are any questions, please let me know; I value this open-source opportunity and experience.

@SkyeBeFreeman
Copy link
Collaborator

I checked out your branch and run the QuickstartCalleeServiceA. There is still heartbeat and logs shows below. BTW, you should see my PR to your repo(zihenzzz#1).

Clipboard_Screenshot_1750212186

@zihenzzz
Copy link
Author

zihenzzz commented Jun 18, 2025

b7b52acc847453018e0d44b3b935da1

Neither the run log nor the log file appears [AsyncHeartbeat]Instance heartbeat task started and [AsyncHeartbeat]Instance heartbeat success.

@SkyeBeFreeman
Copy link
Collaborator

please merge this PR zihenzzz#1

heartbeat(heartbeatRequest);

// Always use registerInstance to avoid automatic heartbeat
instanceRegisterRequest.setTtl(polarisDiscoveryProperties.getHeartbeatEnabled() ?
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you should modify com.tencent.polaris.api.core.ProviderAPI#registerInstance but not set a big heartbeat TTL.

@zihenzzz
Copy link
Author

zihenzzz commented Jun 18, 2025 via email

@zihenzzz zihenzzz requested a review from SkyeBeFreeman June 19, 2025 03:35
@zihenzzz zihenzzz changed the title fix #1565 fix polaris.discovery.heartbeat.enabled is not effective #1565 Jun 19, 2025
@SkyeBeFreeman
Copy link
Collaborator

Sorry. I have been busy recently, so I will continue this part of the work next month.

@SkyeBeFreeman SkyeBeFreeman added this to the 2.0.3.x milestone Jun 20, 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.

polaris.discovery.heartbeat.enabled is not effective
3 participants