Add leader election recovery with generation isolation#92
Open
ssteele110 wants to merge 1 commit intomasterfrom
Open
Add leader election recovery with generation isolation#92ssteele110 wants to merge 1 commit intomasterfrom
ssteele110 wants to merge 1 commit intomasterfrom
Conversation
Implement leader election architecture to handle master worker death during queue population. Key changes: - Add MasterDied exception for detecting master failures - Add master_lock_ttl (30s) and max_election_attempts (3) config options - Use SET NX EX for master lock with TTL instead of SETNX (no TTL) - Namespace all queue data keys by generation UUID for isolation - Detect master death in wait_for_master when lock expires during setup - Add retry loop in populate() to handle MasterDied with configurable attempts - Add generation staleness check in poll loop - Update all queue operations to use generation-scoped keys This allows workers to recover when a master dies mid-population by: 1. Detecting the lock expiry (MasterDied exception) 2. Electing a new master with a new generation 3. Repopulating the queue in an isolated namespace 4. Old workers detect staleness and exit gracefully Co-Authored-By: Claude Opus 4.5 <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.
Summary
MasterDiedexception for detecting master failures during setupmaster_lock_ttl(30s default) andmax_election_attempts(3 default)SET NX EXfor master lock with TTL instead ofSETNX(which had no TTL)How It Works
SET key "setup:{uuid}" NX EX 30(30s TTL)MasterDiedexceptionbuild:{id}:gen:{uuid}:*Test plan
🤖 Generated with Claude Code