shenyu icon indicating copy to clipboard operation
shenyu copied to clipboard

[BUG] Cluster master election scheduler can stop after one renewal exception

Open Aias00 opened this issue 4 months ago • 2 comments

Current Behavior

Cluster master election/renewal can stop permanently after one exception escapes the scheduled task.

ShenyuClusterService.startSelectMasterTask() schedules master selection with scheduleAtFixedRate(...):

executorService.scheduleAtFixedRate(() -> doSelectMaster(host, port, contextPath), ...);

doSelectMaster() catches exceptions, closes the check services, and then throws a new ShenyuException:

} catch (Exception e) {
    LOG.error("select master error", e);
    upstreamCheckService.close();
    instanceCheckService.close();
    throw new ShenyuException(...);
}

For ScheduledThreadPoolExecutor, an exception escaping a fixed-rate task suppresses later executions of that periodic task. A transient lock/renewal failure can therefore stop future master selection attempts in that process.

Expected Behavior

Master election/renewal errors should be logged and the next scheduled election attempt should still run. Exceptions should not escape the periodic scheduler task.

Impact

After a transient cluster backend failure, the admin node may stop participating in master election until it is restarted.

Code Location

  • shenyu-admin/src/main/java/org/apache/shenyu/admin/mode/cluster/service/ShenyuClusterService.java
    • startSelectMasterTask() schedules the periodic task.
    • doSelectMaster() rethrows from the catch block.

Aias00 avatar Jul 31 '26 07:07 Aias00

👋 Hello @Aias00

A new issue has been opened by @Aias00:

  • Title: [BUG] Cluster master election scheduler can stop after one renewal exception
  • Link: https://github.com/apache/shenyu/issues/6495

Please review when you have time. Thank you! 🙏

github-actions[bot] avatar Jul 31 '26 08:07 github-actions[bot]

Confirmed this still exists on current upstream/master: startSelectMasterTask() schedules doSelectMaster directly, and its exception path rethrows ShenyuException, which cancels later fixed-rate executions. I plan a focused scheduler-boundary guard for the expected ShenyuException path (leaving fatal Errors visible), preserving the existing service-close and lock-release behavior, with a regression test proving a later scheduled election still runs after one failed attempt.

sunnysabor avatar Oct 01 '26 17:10 sunnysabor