Phase 10: automatic cluster membership lifecycle#87
Merged
Conversation
Add state_cluster_membership: a background component that manages
peer lifecycle through heartbeat emission, failure detection, and
automatic eviction.
Heartbeat emission:
Periodically publishes OOB messages on __system.membership.<cluster>.<node>
so other nodes know this process is alive.
Failure detection:
Tracks last_heartbeat_ns per peer and transitions through states:
alive -> suspect (after suspect_timeout)
suspect -> dead (after dead_timeout)
dead -> evicted (removed from peer_registry + replica)
Event callbacks:
peer_joined, peer_suspect, peer_dead, peer_evicted events fire
from the tick loop thread for other components to react.
Inbound heartbeats:
on_heartbeat() auto-registers unknown peers and refreshes liveness.
Suspect/dead peers are restored to alive on fresh heartbeat.
Observability:
Counters for heartbeats sent/received, peers suspected/dead/evicted/joined.
Clock injection via set_clock() for deterministic testing.
21 tests cover construction, start/stop, peer registration, heartbeat
processing, failure detection through all states, event callbacks,
config updates, and two-node integration with shard + transport.
9e13f68 to
3823a1b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
state_cluster_membership: a background component that manages peer lifecycle through heartbeat emission, failure detection, and automatic eviction.Components
state_cluster_membership(header + implementation + 21 tests)Heartbeat Emission
__system.membership.<cluster>.<node>Failure Detection
Tracks
last_heartbeat_nsper peer with three-stage state machine:suspect_timeout(default 3s)dead_timeout(default 5s)evict_timeout(default 10s) — removes frompeer_registry+replicaEvent Callbacks
peer_joined,peer_suspect,peer_dead,peer_evictedeventsadd_callback()/remove_callback()Inbound Heartbeat Processing
on_heartbeat()auto-registers unknown peers in registry + replicaObservability
set_clock()for deterministic testingpeer_registry,replica,shard, andtransportTests (21)
Construction, start/stop lifecycle, peer registration, heartbeat processing, failure detection through all states (suspect/dead/evict), heartbeat revival, event callbacks, config updates, and two-node integration with shard + inproc transport.