Protect CHK recreate with live Raft quorum safety - #2070
Open
alex-zaitsev wants to merge 5 commits into
Open
Conversation
alex-zaitsev
force-pushed
the
fix/2069-chk-raft-quorum-safety
branch
from
August 22, 2026 10:42
4c78e49 to
44f3a37
Compare
Capturing shouldWaitHostReady before force-restart avoids Started-only after ReadyReplicas drops to 0, which let 3→1 downscale complete while the survivor was still 0/1. Co-authored-by: Cursor <cursoragent@cursor.com>
Replace abort-on-quorum-refuse with a wait-then-defer flow, recovery-first host ordering, and a CHI-style single late disrupt gate with an early ensemble snapshot. Add test_020003_3 for interrupted Keeper rolls. Co-authored-by: Cursor <cursoragent@cursor.com>
Use atomic.Int32 for the ready-count stub shared between the wait loop and the goroutine that simulates a peer recovering. Co-authored-by: Cursor <cursoragent@cursor.com>
alex-zaitsev
force-pushed
the
fix/2069-chk-raft-quorum-safety
branch
from
August 22, 2026 17:00
7a1fa9c to
41cae72
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.
Summary
Fixes #2069 (CHK Raft quorum safety during rolls) and #2035 (remove pointless same-size settle delay). Partial #2059 (status persistence).
#2069 — quorum-safe rolls
On a multi-node CHK, the operator must not disrupt a Ready Keeper replica if doing so would drop the ensemble below Raft majority.
Flow (CHI #1704-shaped late gate, CHK-specific early snapshot):
snapshotHostEnsemble— before any STS disruption, recordrollingand live Ready counts.rollingis frozen through force-restart soReadyReplicas→0does not re-classify the pass as bootstrap.PrepareHostStatefulSetWithStatus→ set STS wait mode (Readyif rolling,Startedonly if bootstrap).hostDisruptionWouldBreakQuorum— single late gate (same placement as CHIhostDisruptionWouldDegradeShard).waitForQuorumSafeToDisruptHost(poll 5s, max 2m) →ErrCRUDDeferred(not whole-CR abort). Status gets[RaftQuorumUnsafe]. Deferral is per replica — the operator continues with the remaining Keeper nodes in the ensemble, then requeues.chkStatefulSetFallback→ErrCRUDAborton STS create/update wait failure — stops advancing to the next replica while the previous one never rejoined (ClickHouseKeeperInstallation controller can recreate every replica of an ensemble without keeping a Raft quorum running #2069 root cause).Rolling vs bootstrap (from live Ready, not CR ancestor):
n≤1orready ≥ quorumNot in this PR: full #2041 committed-config /
mntrbarrier (verifyHostEnsembleMembershipis a no-op hook). Staged rescale (3→2→1) and smarter per-step downscale settle are follow-ups.#2035 / partial #2059
membershipSettleDelay→ 0 (was a fixed 10s).Completedis persisted.Comparison with CHI shard safety (#1704)
ErrCRUDDeferredErrCRUDDeferredTest plan
go test ./pkg/controller/chk/(quorum, snapshot, gate, wait/defer, recovery-first, settle delay, status persist)test_020005xfail removedtest_020003/test_020005(keeper upgrade / scale)test_020003_3— 3-node CHK, broken-image roll stops on replica 0, peers stay Ready through operator restart, recovery to good image (CHItest_010083analogue)Follow-ups (separate PRs)
verifyHostEnsembleMembership