[BUG] Consul TTL heartbeat task can stop after one transient Consul error
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
### Current Behavior
Consul registry TTL heartbeats can stop permanently after one `agentCheckPass` failure.
`TtlScheduler.add()` schedules each heartbeat with `scheduleAtFixedRate(...)`:
```java
this.scheduler.scheduleAtFixedRate(new ConsulHeartbeatTask(instanceId), ttl, ttl, TimeUnit.SECONDS);
```
The task calls Consul directly and does not catch exceptions:
```java
TtlScheduler.this.client.agentCheckPass(this.checkId);
```
If Consul is temporarily unavailable or the request fails once, the exception escapes the fixed-rate task. `ScheduledThreadPoolExecutor` suppresses later executions of that periodic task after an uncaught exception.
### Expected Behavior
A transient Consul heartbeat failure should be logged and retried on the next TTL interval. Exceptions should not escape the scheduled heartbeat task.
### Impact
A registered instance can stop sending TTL pass updates after a single transient Consul error, causing Consul to mark it unhealthy until the instance re-registers or restarts.
### Code Location
- `shenyu-registry/shenyu-registry-consul/src/main/java/org/apache/shenyu/registry/consul/TtlScheduler.java`
- `add()` schedules the heartbeat task.
- `ConsulHeartbeatTask.run()` calls `agentCheckPass(...)` without exception handling.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in shenyu-registry/shenyu-registry-consul/src/main/java/org/apache/shenyu/registry/consul/TtlScheduler.java, reading add() and ConsulHeartbeatTask.run(). Check how scheduled-task exceptions affect later executions, then verify that a failed agentCheckPass call is logged and the heartbeat runs again on the next TTL interval without requiring re-registration or restart.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100