Aias00 opened a new issue, #6496:
URL: https://github.com/apache/shenyu/issues/6496
### 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.
--
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]