Aias00 opened a new issue, #7748: URL: https://github.com/apache/shenyu/issues/7748
## Current behavior `InstanceCheckService.close()` invokes `syncDB()` before clearing the local map and calling `executor.shutdown()`. There is no finally block. When `InstanceInfoService.createOrUpdate` throws during the final flush, execution exits before executor cleanup. The checker executor is created with non-daemon threads. This can leave scheduled checking/persistence work active after the bean's shutdown callback fails and can interfere with graceful process/context shutdown. This path also appears when `close()` is called during cluster error handling. The exact process-exit effect depends on the surrounding shutdown lifecycle. ## Source evidence - [Close ordering without finally](https://github.com/apache/shenyu/blob/66d7d954ca37d651a5ad916f988a8081157a7ab4/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/InstanceCheckService.java#L183) - [Non-daemon executor creation](https://github.com/apache/shenyu/blob/66d7d954ca37d651a5ad916f988a8081157a7ab4/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/InstanceCheckService.java#L85) - [Database call can throw on update](https://github.com/apache/shenyu/blob/66d7d954ca37d651a5ad916f988a8081157a7ab4/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/InstanceInfoServiceImpl.java#L70) - [Cluster error cleanup caller](https://github.com/apache/shenyu/blob/66d7d954ca37d651a5ad916f988a8081157a7ab4/shenyu-admin/src/main/java/org/apache/shenyu/admin/mode/cluster/service/ShenyuClusterService.java#L104) ## Deterministic regression scenario Initialize the checker and add an observed instance. Configure a mock persistence service to throw during the final synchronization. Invoke `close()` and verify the owned executor is shut down and cleanup completes even though persistence failed. Clean up any test-owned threads unconditionally. No long sleeps or real database outage is needed for this regression. This issue was verified by source/control-flow inspection; the regression and a process-level graceful-shutdown test were not run during issue preparation. ## Acceptance criteria - [ ] Executor/resource cleanup runs regardless of final persistence success or failure. - [ ] Stop accepting/scheduling new work and bound any waiting for outstanding work; preserve explicit behavior for failure of the best-effort final flush. - [ ] Avoid clearing state while still-running tasks can repopulate or persist it without a documented lifecycle policy. - [ ] Test final-flush failure, normal shutdown, repeated close and close-before-setup with deterministic executor assertions. - [ ] Test cleanup ordering in the cluster error path without masking the original cause; no non-daemon checker thread remains after the documented shutdown bound. Related: #6496 covers periodic sync cancellation after an exception, not cleanup in `close`. #6705 fixed the null executor when setup never ran; its existing no-setup test does not cover final-flush failure. #7744 concerns scheduler starvation by slow 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]
