Skip to content

fix(im): recover channels after leader lock loss - #2365

Merged
lyingbug merged 1 commit into
Tencent:mainfrom
March-77:agent/recover-feishu-leader-lock
Jul 28, 2026
Merged

fix(im): recover channels after leader lock loss#2365
lyingbug merged 1 commit into
Tencent:mainfrom
March-77:agent/recover-feishu-leader-lock

Conversation

@March-77

Copy link
Copy Markdown
Contributor

Description

Restore an in-process recovery path when a WebSocket or long-poll IM runtime loses its Redis leader lease.

The renewal loop now stops the adapter and schedules the channel through the existing leader takeover loop. That loop already re-reads the durable channel row before reconnecting, preserving delete/disable/config freshness checks and the per-channel retry deduplication guard.

Root cause

wsLeaderRenewLoop called StopChannel and returned when renewal failed or ownership was lost. Only startup-time acquisition failures entered wsLeaderRetryLoop, so an enabled Feishu WebSocket channel could remain inactive until the app restarted.

Impact

Transient Redis renewal failures or lease replacement no longer leave enabled channels permanently stopped. Duplicate loss handling remains idempotent, and a channel deleted or disabled while waiting is not resurrected.

Testing

  • go test ./internal/im -run 'TestLeadershipLossStopsAdapterAndSchedulesRecovery|TestLeaderElectionFailsClosedWhenRedisUnavailable' -count=1
  • git diff --check

Fixes #2344

@March-77
March-77 marked this pull request as ready for review July 28, 2026 09:29
@lyingbug
lyingbug merged commit d59151d into Tencent:main Jul 28, 2026
1 check passed
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]: Feishu WebSocket channel does not recover after Redis leader-lock renewal failure

2 participants