[BUG] Instance health DB sync scheduler can stop after one persistence error
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
### Current Behavior
`InstanceCheckService` protects the heartbeat state-check task from exceptions, but the periodic DB sync task is scheduled directly with no exception guard.
```java
executor.scheduleWithFixedDelay(this::scheduled, 30, scheduledTime, TimeUnit.SECONDS);
executor.scheduleWithFixedDelay(this::syncDB, 40, scheduledTime, TimeUnit.SECONDS);
```
`scheduled()` catches and logs exceptions, but `syncDB()` does not:
```java
public void syncDB() {
instanceHealthBeatInfo.values().forEach(vo -> {
instanceInfoService.createOrUpdate(vo);
});
}
```
If `instanceInfoService.createOrUpdate(...)` throws once, for example due to a transient database error, the exception escapes the scheduled task. `ScheduledThreadPoolExecutor` then suppresses subsequent executions of that fixed-delay task.
### Expected Behavior
A DB sync failure should be logged and retried in the next scheduled run, rather than stopping all future instance-state persistence.
### Impact
After a transient persistence error, in-memory instance health can continue changing while DB state is no longer updated until the admin process restarts.
### Code Location
- `shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/InstanceCheckService.java`
- `setup()` schedules `syncDB` directly.
- `syncDB()` has no exception handling around persistence.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/InstanceCheckService.java, reading setup(), scheduled(), and syncDB(). Compare how scheduled() handles exceptions with the direct syncDB scheduling, then verify that a persistence failure is logged and a later scheduled run still updates the database.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100