Keeps the shared Redis state honest when a node dies without cleaning up.
Every tick (10s) this process:
- Heartbeats — refreshes this node's TTL key (
<prefix>:node:<id>, 30s). - Resyncs — if that key had vanished (Redis restarted or was
flushed, or this node was cut off long enough for it to expire), or the
previous heartbeat failed, this node's live occupancy and presence are
written back into Redis (
PusherServer.Backend.Redis.resync/1), so a Redis restart doesn't leave connected clients invisible. - Reaps (one node at a time, guarded by a short Redis lock) — finds
presence entries and channel-subscription counts that belong to a
node whose key has expired, removes them, and announces the
resulting
member_removed/channel_vacatedevents to the cluster, exactly as if the dead node's sockets had disconnected normally.
On a graceful stop the node deletes its own key so peers reap it at the next tick instead of waiting out the TTL.
A node that is alive but cut off from Redis for longer than the TTL is
indistinguishable from a dead one, so peers remove its presence/occupancy
(and announce member_removed). When it reconnects it restores that state
silently, so its users reappear in the member list without a fresh
member_added. Keep Redis reachable, or raise the TTL, if that matters.
Summary
Functions
Returns a specification to start this module under a supervisor.
Removes presence and occupancy state left behind by dead nodes. Called automatically; exposed so it can be triggered directly (tests, ops).
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Removes presence and occupancy state left behind by dead nodes. Called automatically; exposed so it can be triggered directly (tests, ops).