[BUG] Instance health DB sync scheduler can stop after one persistence error
Current Behavior
InstanceCheckService protects the heartbeat state-check task from exceptions, but the periodic DB sync task is scheduled directly with no exception guard.
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:
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.javasetup()schedulessyncDBdirectly.syncDB()has no exception handling around persistence.
👋 Hello @yuluo-yx
A new issue has been opened by @Aias00:
- Title: [BUG] Instance health DB sync scheduler can stop after one persistence error
- Link: https://github.com/apache/shenyu/issues/6496
Please review when you have time. Thank you! 🙏
I opened PR #7414 for this member of #6608. It isolates each scheduled persistence call so one failing instance is logged without cancelling the fixed-delay task or preventing the other cached instances from syncing; a later run retries the failed entry. The synchronous syncDB() path used during shutdown is unchanged. The focused InstanceCheckServiceTest and full shenyu-admin suite both pass locally.