Repository navigation
Sharded clusters: rolling restarts and KividbDbOps restarts - #14
Closed
murtazayusuf wants to merge 1 commit into
Closed
murtazayusuf wants to merge 1 commit into
murtazayusuf wants to merge 1 commit into
Conversation
Template changes and KividbDbOps restarts replace one pod at a time across the cluster, replicas first, while every slot is served and every other pod is in sync. A shard's master steps down first: its most caught-up replica takes over with CLUSTER FAILOVER (new agent endpoint /cluster/failover), and the move is a ShardSwitchover, not a failover. A shard without replicas restarts its master in place.
This was referenced Oct 24, 2026
Contributor
Author
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.
Stacked on #13 (then #12, #11, #10). The diff is against #13.
This is the fifth step of 0.7.0: sharded clusters get rolling restarts. Until now a shard's StatefulSet (OnDelete) never replaced its pods, so a template change, a new password or a config change didn't take effect, and
KividbDbOpsrefused sharded clusters.Rollout (
shard_rollout.go)The rules are the same as for a replicated set (
reconcileRollout), applied across the whole cluster:cluster_state:ok, and every other pod ready and healthy. Healthy means a master owning its shard's slots, or a replica in sync with it.kividb.io/step-down) on its pod.CLUSTER FAILOVER. That is the coordinated mode: the master pauses writes and the replica catches up before it wins the election, so no acknowledged write is lost. I checkedcmd_failover/run_manual_failoverin kividb.replicas: 0: the shard has no one to hand over to, so its master restarts in place and its slots are down until it is back. This is documented.Sync for shard replicas
/cluster/statusnow reportsmasterLinkUp(master_link_status).maxSyncLagBytesas today).status.pods[].syncedis now set for sharded clusters.Planned moves are not failovers
When the old master's pod carries the step-down annotation, the move is recorded as a
ShardSwitchoverEvent (Normal). It does not raise aShardFailoverwarning and does not setlastFailoverTime. The annotation is removed once the pod is a replica.KividbDbOpsrestartstatus.shards[].masterPod.cluster_state:ok.Agent
POST /cluster/failoversendsCLUSTER FAILOVER; the engine refuses it on a master. Behind the agent token, like the other endpoints.Tested
go build,go vet,go test ./...andhelm lintpass.CLUSTER FAILOVER(slots and replicas move to the replica), offsets and the link state. Tests inshard_rollout_test.go:-1is master and each-0follows it;ShardSwitchoverevents, noShardFailover, nolastFailoverTime;replicas: 0: the masters are restarted one by one.KividbDbOps: master detection by shard, an in-sync replica from another shard doesn't count, and the wait forcluster_state:ok.