Skip to content

fix: offload websocket reconnect from shared timer to dedicated executor - #6898

Open
wy471x wants to merge 1 commit into
apache:masterfrom
wy471x:fix_shenyuwebsocketclient-reconnecting
Open

fix: offload websocket reconnect from shared timer to dedicated executor#6898
wy471x wants to merge 1 commit into
apache:masterfrom
wy471x:fix_shenyuwebsocketclient-reconnecting

Conversation

@wy471x

@wy471x wy471x commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • ShenyuWebsocketClient.healthCheck() previously called reconnectBlocking() directly on the shared wheel timer's single-thread executor. When an admin was unreachable, the TCP connect timeout blocked all other timer tasks (other clients' health checks, masterCheck), causing missed heartbeats and delayed failover.
  • Offloaded reconnect to a dedicated CachedThreadPool executor so the timer thread is never blocked.
  • Added exponential backoff with jitter (1s–60s) and an AtomicBoolean guard to prevent concurrent reconnect attempts for the same client.

Test plan

  • calculateBackoff() returns 0 for no failures, exponential growth for failures 1-10, capped at 60s, with jitter
  • healthCheck() resets backoff on healthy connection, does not double-submit reconnects
  • doReconnect() increments backoff on failure (capped at 10), resets reconnecting in finally, applies backoff sleep, preserves interrupt status
  • All 15 tests pass (11 new + 4 existing)

close #6844

healthCheck() called reconnectBlocking() on the shared wheel timer's
single-thread executor, blocking all other timer tasks (other clients'
health checks, masterCheck) during TCP connect timeout. Offload
reconnect to a dedicated CachedThreadPool executor with exponential
backoff + jitter (1s-60s) and an AtomicBoolean guard to prevent
concurrent reconnect attempts.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] ShenyuWebsocketClient.healthCheck reconnectBlocking blocks the shared single-thread wheel timer

1 participant