harshkha3417 opened a new pull request, #7765:
URL: https://github.com/apache/shenyu/pull/7765

   Fixes #6608 (and addresses sub-issues #6495, #6496).
   
   Periodic tasks scheduled via `ScheduledThreadPoolExecutor` 
(`scheduleAtFixedRate` / `scheduleWithFixedDelay`) are permanently cancelled if 
an unhandled exception escapes the task execution (per the JDK 
`ScheduledExecutorService` specification: *"if any execution of the task 
encounters an exception, subsequent executions are suppressed"*).
   
   Following an audit of the recurring task issues tracked under #6608:
   - In `ShenyuClusterService` (#6495), `doSelectMaster` rethrew 
`ShenyuException` across the scheduler boundary upon an election or renewal 
failure. This permanently killed the master election loop on that node.
   - In `InstanceCheckService` (#6496), `syncDB()` was scheduled without 
exception guards around `instanceInfoService.createOrUpdate()`, so a transient 
persistence failure would permanently terminate database synchronization.
   
   ### Modifications
   
   1. **`ShenyuClusterService`**:
      - Prevented runtime exceptions from escaping `doSelectMaster()` to ensure 
the master election scheduler remains active across periods.
      - Preserved service cleanup (`upstreamCheckService.close()`, 
`instanceCheckService.close()`) and lock release (`releaseMaster()`) in a 
`finally` block when the node is no longer master.
      - Handled `InterruptedException` cleanly and added 
`executorService.shutdown()` in `shutdown()`.
   
   2. **`InstanceCheckService`**:
      - Wrapped `syncDB()` with exception handling so that a persistence 
failure on an individual instance does not suppress updating the remaining 
instances or kill the periodic sync schedule.
   
   3. **Tests**:
      - Added `ShenyuClusterServiceTest` covering recovery after election 
failure, renewal failure cleanup, and shutdown.
      - Added `testSyncDBContinuesOnException` in `InstanceCheckServiceTest` to 
ensure persistence errors do not cancel subsequent cycles.
   
   ### Verification
   
   - Run unit tests:
     ./mvnw test -pl shenyu-admin 
-Dtest='ShenyuClusterServiceTest,InstanceCheckServiceTest'


-- 
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]

Reply via email to