Sean-Walker0 opened a new pull request, #7432:
URL: https://github.com/apache/shenyu/pull/7432
Fixes #6498
## Modifications
`TtlScheduler.ConsulHeartbeatTask#run` called
`client.agentCheckPass(checkId)` directly inside a `scheduleAtFixedRate` task
with no exception guard. `ScheduledThreadPoolExecutor` suppresses all later
executions of a periodic task once an exception escapes it, so a single
transient Consul error (restart, network blip, 5xx) permanently stopped the TTL
heartbeat for that instance — and Consul would eventually mark it unhealthy
even though the instance was alive.
The task now catches the failure, logs it, and lets the next scheduled beat
retry:
```java
try {
TtlScheduler.this.client.agentCheckPass(this.checkId);
...
} catch (Exception e) {
// an exception escaping a fixed-rate task suppresses all later
executions,
// so a single failed heartbeat must only be logged to keep beating
log.error("Sending consul heartbeat for: " + this.checkId + " failed",
e);
}
```
## Verifying this change
- [x] New `TtlSchedulerTest#heartbeatKeepsBeatingAfterFailure` — the first
`agentCheckPass` throws, the second succeeds, and the heartbeat must fire at
least twice within the window. Red on the pre-fix code (`Wanted *at least* 2
times` — only one invocation happened, the task died after the first failure),
green after.
- [x] `./mvnw -pl shenyu-registry/shenyu-registry-consul -am test -B` — 4/4
module tests green, checkstyle clean.
## Notes
- Behavior change: a failed heartbeat is logged (ERROR) instead of silently
killing the task; successful beats are unchanged.
- Same bug family as #6500 (Eureka watch, fixed in #7429) and the sibling
reports #6495/#6496 (covered by PRs #7406/#7414); each is fixed separately per
repository.
- Orthogonality: #7042 (open) modifies `TtlScheduler#remove`/`shutdown` and
`ConsulInstanceRegisterRepository#close` — different methods in the same files;
its diff was compared line by line and does not touch `ConsulHeartbeatTask`, so
the changes do not overlap.
Make sure that:
- [x] You have read the [contribution
guidelines](https://shenyu.apache.org/community/contributor-guide).
- [x] You submit test cases (unit or integration tests) that back your
changes.
- [x] Your local test passed `./mvnw clean install
-Dmaven.javadoc.skip=true` (module-scoped:
`shenyu-registry/shenyu-registry-consul` with `-am`, tests + checkstyle green).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]