Hand the master role over before replacing the master pod - #26
Merged
Merged
Conversation
Requiring a ready replica before deleting the master removed the case where there was nothing to promote, but not the outage itself: the operator still deleted the master and elected a replacement on a later reconcile. That gap measured up to 11.5s in CI and about 30s on a production cluster. Promote the best replica first and leave the old master pod running. Once demoted it is just a replica with a stale revision, so the existing slave loop replaces it behind the same readiness quorum as any other replica. There is a master at every instant. This is the ordering redis documents for upgrades and that spotahome#637 describes as a seamless rollout: replicas first, then a failover, then the old master. Sentinel mode is untouched and still deletes the master so sentinel runs the failover. Refs #23
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Sep 28, 2026
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.
Follow-up to #24, which was incomplete.
Requiring a ready replica before deleting the master removed the pathological case (59s masterless, nothing to promote) but left the ordering unchanged: the operator still deleted the master and elected a replacement on a later reconcile. On main that detection-and-promotion gap measured 11.5s on k8s 1.36.4, which is why main is currently red — the availability assertion caught it correctly.
Change
Promote the best replica first, then leave the old master pod alone. Once demoted it is simply a replica with a stale revision, so the existing slave loop replaces it behind the same readiness quorum as any other replica. There is a master at every instant.
Reuses
GetBestReplicaForPromotionandPromoteBestReplica, already used by the no-master branch.GetReplicaReplicationOffsetsskips masters, so the selector is safe to call while a master is live.Sentinel mode is untouched: it still deletes the master so sentinel runs the failover.
The e2e threshold goes back to 1 sample, since there should now be no window at all.