-
Notifications
You must be signed in to change notification settings - Fork 507
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
base: 2022
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
...laris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisServiceRegistry.java
Outdated
Show resolved
Hide resolved
...nt-polaris-discovery/src/main/java/com/tencent/cloud/polaris/PolarisDiscoveryProperties.java
Show resolved
Hide resolved
If there is any problem, please let me know and I will correct it as soon as possible. |
@zihenz If the heartbeat is disabled and polarisDiscoveryProperties.getHealthCheckUrl() is null, the heartbeat report will still be performed. You can try this. |
...nt-polaris-discovery/src/main/java/com/tencent/cloud/polaris/PolarisDiscoveryProperties.java
Show resolved
Hide resolved
If there are any questions, please let me know; I value this open-source opportunity and experience. |
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). ![]() |
please merge this PR zihenzzz#1 |
heartbeat(heartbeatRequest); | ||
|
||
// Always use registerInstance to avoid automatic heartbeat | ||
instanceRegisterRequest.setTtl(polarisDiscoveryProperties.getHeartbeatEnabled() ? |
There was a problem hiding this comment.
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.
docs:update CHANGELOG.
…-cloud-tencent into feat-network-fix
If there are any issues, please let me know. I hope to have a complete experience of contributing code, and I value this opportunity very much
…---Original---
From: "Haotian ***@***.***>
Date: Wed, Jun 18, 2025 13:22 PM
To: ***@***.***>;
Cc: ***@***.******@***.***>;
Subject: Re: [Tencent/spring-cloud-tencent] fix #1565 (PR #1621)
@SkyeBeFreeman requested changes on this pull request.
In spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisServiceRegistry.java:
> @@ -138,42 +129,37 @@ public void register(PolarisRegistration registration) { try { ProviderAPI providerClient = polarisSDKContextManager.getProviderAPI(); InstanceRegisterResponse instanceRegisterResponse; - if (StringUtils.isBlank(polarisDiscoveryProperties.getHealthCheckUrl())) { - instanceRegisterResponse = providerClient.registerInstance(instanceRegisterRequest); - } - else { - instanceRegisterResponse = providerClient.register(instanceRegisterRequest); - InstanceHeartbeatRequest heartbeatRequest = new InstanceHeartbeatRequest(); - BeanUtils.copyProperties(instanceRegisterRequest, heartbeatRequest); - heartbeatRequest.setInstanceID(instanceRegisterResponse.getInstanceId()); - // Start the heartbeat thread after the registration is successful. - heartbeat(heartbeatRequest); + + // Always use registerInstance to avoid automatic heartbeat + instanceRegisterRequest.setTtl(polarisDiscoveryProperties.getHeartbeatEnabled() ?
I think you should modify com.tencent.polaris.api.core.ProviderAPI#registerInstance but not set a big heartbeat TTL.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Sorry. I have been busy recently, so I will continue this part of the work next month. |
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