You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add leader election recovery with generation isolation
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>
0 commit comments