Repository navigation
Conversation
ActionPlan.WalkRemoved/WalkAdded walked the messagediff spec diff, which compares slices by index. Removing replicas anywhere but at the tail of layout.shards[].replicas reported the tail (kept) hosts as removed, so the operator ran SYSTEM DROP REPLICA for live replicas. Inserting a replica in the middle marked the wrong host as added. Match clusters, shards and hosts by name between the old and new CR instead. Run DROP REPLICA on a host of the same shard that survives in the new CR rather than on the first host of the old shard, which may already be purged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
@Slach , need e2e test with repro and demonstration of a fix. |
ActionPlan.WalkRemoved/WalkAdded walked the messagediff spec diff, which compares slices by index. Removing replicas anywhere but at the tail of layout.shards[].replicas reported the tail (kept) hosts as removed, so the operator ran SYSTEM DROP REPLICA for live replicas. Inserting a replica in the middle marked the wrong host as added. Match clusters, shards and hosts by name between the old and new CR instead. Run DROP REPLICA on a host of the same shard that survives in the new CR rather than on the first host of the old shard, which may already be purged. Fixes #1545 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Slach
force-pushed
the
fix/1545-drop-replica-by-name
branch
from
November 3, 2026 05:02
e09be00 to
9cd1d31
Compare
…ection by pod name, extend test_010089 (#1545) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lickhouse-operator into fix/1545-drop-replica-by-name # Conflicts: # pkg/controller/chi/worker-deleter.go # pkg/controller/chi/worker-deleter_test.go
This branch has not been deployed
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.
Problem
If a shard has explicitly named replicas and the user removes entries that are not at the tail of
layout.shards[].replicas(for example0-0, 0-1, 0-2are removed and0-*-dedicatedare kept), the operator runsSYSTEM DROP REPLICAfor the replicas it keeps. It also runs that SQL on a pod that has already been deleted (no such host). StatefulSets and pods are removed correctly. Inserting a replica in the middle of the list marks the wrong host as added.Root cause
ActionPlan.WalkRemoved/WalkAddedwalk themessagediffspec diff. That diff compares slices by index, so the hosts it reports as removed or added are the positional tail of the list, not the hosts whose names were removed or added.dropZKReplicaruns the SQL onhostToDrop.GetShard().FirstHost(), which comes from the old CR. By the timedropZKReplicasruns,clean()may already have purged that host.Fix
WalkRemoved/WalkAddednow match items by name between the old and new CR: cluster, then shard within the cluster, then host within the shard. They still report the most specific missing item (a whole cluster, a whole shard, or a host).WalkModifiedis unchanged.dropZKReplicasnow runsSYSTEM DROP REPLICAon a host of the same cluster and shard that survives in the new CR. If no such host exists, it skips with the existing error log. All gating stays the same:reconcile.host.drop.replicas.onDelete, retained volumes, and the force-drop path in the migrator.Tests
TestActionPlanWalkByNamecovers removing the head, tail and middle replicas, inserting a replica in the middle, removing a whole shard or cluster, and a no-op change. The head, middle and insert cases fail on the old code.TestSurvivingShardHostchecks that the host chosen to runDROP REPLICAcomes from the new CR and belongs to the same shard.go build ./...,go vet -copylocks=false -printf=false ./pkg/apis/... ./pkg/controller/...andgo test -vet=off -race -count=1 ./pkg/apis/... ./pkg/controller/...all pass.fixes #1545
🤖 Generated with Claude Code