Repository navigation
Description
Background
A 2026-08-02 source audit confirmed that 8 open issues share the same root cause: a periodic task scheduled via ScheduledThreadPoolExecutor (either scheduleAtFixedRate or scheduleWithFixedDelay) is permanently cancelled after a single uncaught exception, because the JDK contract states "if any execution of the task encounters an exception, subsequent executions are suppressed." Confirmed that org.apache.shenyu.common.exception.ShenyuException extends RuntimeException, so rethrows escape the task and kill the schedule.
This one defect class silently stops cluster election, instance health sync, registry watches, token refresh, heartbeat, and the upstream health-check loop — a broad class of "the gateway/admin silently stops reconciling" symptoms.
Affected issues (all verified VALID)
- [BUG] Client heartbeat scheduler can stop permanently after one full failure #6487 Client heartbeat scheduler can stop permanently after one full failure
- [BUG] Cluster master election scheduler can stop after one renewal exception #6495 Cluster master election scheduler can stop after one renewal exception
- [BUG] Instance health DB sync scheduler can stop after one persistence error #6496 Instance health DB sync scheduler can stop after one persistence error
- [BUG] Consul TTL heartbeat task can stop after one transient Consul error #6498 Consul TTL heartbeat task can stop after one transient Consul error
- [BUG] Consul instance watch task can stop after one polling error #6499 Consul instance watch task can stop after one polling error
- [BUG] Eureka instance watch task can stop after one polling error #6500 Eureka instance watch task can stop after one polling error
- [BUG] Upstream health check can get stuck after one async check failure #6502 Upstream health check can get stuck after one async check failure
- [BUG] HTTP sync token refresh can stop after a login response parsing error #6504 HTTP sync token refresh can stop after a login response parsing error
Variants observed
- No try/catch at all (task body throws directly): [BUG] Client heartbeat scheduler can stop permanently after one full failure #6487, [BUG] Consul TTL heartbeat task can stop after one transient Consul error #6498, [BUG] Consul instance watch task can stop after one polling error #6499.
- Catch-and-rethrow as
ShenyuException/RuntimeException(still escapes and cancels): [BUG] Cluster master election scheduler can stop after one renewal exception #6495, [BUG] Eureka instance watch task can stop after one polling error #6500. - Sibling task is guarded but this one isn't: [BUG] Instance health DB sync scheduler can stop after one persistence error #6496 (
scheduled()is wrapped,syncDB()is not). - Aggregation/list bookkeeping fails before
clear(): [BUG] Upstream health check can get stuck after one async check failure #6502 (CompletableFuture.allOf(...).join()re-throws beforefutures.clear()).
Suggested fix pattern (single mechanism closes all 8)
Introduce a common resilient wrapper for periodic tasks in shenyu-common (or a small helper in each module) that:
- Wraps the task body in
try { ... } catch (Throwable t) { LOG.error(...); }so an exception never escapes and cancels the schedule. - For tasks that must surface fatal errors, swallow-and-log for transient errors and escalate (metric/alert) rather than killing the schedule.
- Ensures any shared mutable state (e.g. the
futureslist in [BUG] Upstream health check can get stuck after one async check failure #6502) is cleared in afinally, independent of whetherjoin()succeeded.
Apply it uniformly to ShenyuClusterService, InstanceCheckService, TtlScheduler, ConsulInstanceRegisterRepository, EurekaInstanceRegisterRepository, ShenyuClientURIExecutorSubscriber, AccessTokenManager, and UpstreamCheckService.
Goal
Track the shared fix so the 8 issues can be closed by one well-scoped PR (or a small series) rather than eight independent patches that risk re-implementing the same guard inconsistently.
Audit ref: docs/issue-candidates-2026-08-02.md
Activity
github-actions commentedon Aug 2, 2026
👋 Hello @Aias00
A new issue has been opened by @Aias00:
Please review when you have time. Thank you! 🙏
Aias00 commentedon Aug 3, 2026
Update — round-2 deep-scan (2026-08-02): no NEW "scheduler-stops-after-one-exception" members surfaced; the family of 8 above appears complete for that specific defect class.
The scan did surface three RELATED thread-lifecycle leaks that share the broader "periodic-task / worker-thread lifecycle hardening" theme and could be folded into this pass if its scope is widened. They are DISTINCT defects (idempotent-start / worker-shutdown), not duplicates of the exception-cancellation family — linking for visibility only:
AbstractLogCollector.start()leaks thread pool + consumer thread on repeated calls (idempotent-start defect)SingletonExecutorworker threads never shut down (incomplete [BUG] Resource leak in shenyu-disruptor: OrderlyExecutor is not shut down properly #6262 fix)HierarchicalWheelTimer: non-daemon worker thread never stopped onshutdown()+ unbounded single-thread task executor #6668 PERF-55 —HierarchicalWheelTimernon-daemon worker thread never stopped on shutdown + unbounded executorsunnysabor commentedon Oct 1, 2026
Scope update: PR #7406 addresses the cluster-election member tracked by #6495. It catches
RuntimeExceptiononly at that scheduler boundary, preserving its cleanup/release behavior and allowing the next fixed-rate attempt; fatalErrors remain visible. This is an incremental fix for #6495 only — the other periodic-task issues listed here still need independent validation and fixes. I did not introduce a sharedThrowable-catching wrapper because the affected tasks have different cleanup and recovery semantics.[ISSUE apache#6608] Harden periodic tasks against uncaught exceptions…
[ISSUE apache#6608] Prompt shutdown via shutdownNow, symmetric master…
[ISSUE apache#6608] Prompt shutdown via shutdownNow, symmetric master…
[ISSUE apache#6608] Harden periodic tasks against uncaught exceptions…
[ISSUE apache#6608] Prompt shutdown via shutdownNow, symmetric master…
[ISSUE apache#6608] Harden periodic tasks against uncaught exceptions…
[ISSUE apache#6608] Prompt shutdown via shutdownNow, symmetric master…
[ISSUE apache#6608] Prompt shutdown via shutdownNow, symmetric master…
[ISSUE apache#6608] Prompt shutdown via shutdownNow, symmetric master…
[ISSUE #6608] Prompt shutdown via shutdownNow, symmetric master relea…