feat: distributed probe voting for HA failover coordination#396
Open
Paragrf wants to merge 1 commit into
Open
Conversation
Implement a multi-controller voting mechanism that prevents split-brain during failover: each controller independently probes Kvrocks nodes and the leader collects peer votes before promoting a new master. - Add VoteCoordinator with concurrent HTTP peer voting and quorum logic - Add ClusterChecker.ShouldVote with soft threshold and probe freshness - Add peer registration/discovery and timestamp-based TTL in store layer - Add /internal/vote endpoint with leader-redirect bypass - Add Prometheus metrics for vote rounds, failover blocks, probe failures - Add structured logging for vote diagnostics (failure counts, thresholds) - Fix probe state pruning, redundant store calls, mutex protection Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Background
To enhance the stability of the Kvrocks system, we have implemented an HA (High Availability) system based on multi-controller consensus.
Key Changes
Voting mechanism: Each controller independently probes every Kvrocks node. Before promoting a new master, the leader collects unanimous votes from all peer controllers via POST /internal/vote. A single NO (or unreachable peer with a live lease) blocks the failover.
Peer discovery: Controllers register themselves in the store with a heartbeat. ListActivePeers returns peers whose leases are still alive. Expired peers are excluded from quorum rather than blocking failover.
Observability:Structured zap logging at every vote decision point (round start, per-peer vote with diagnostic fields, round outcome). Seven new Prometheus metrics track failover proposals, completions, blocks, vote round duration, peer count, per-node failure counts, and individual probe failures.
Related Issues
#392