Repository navigation
Closed
Labels
bugplannedThis functionality is planned for implementationresearch requiredThis issue requires additional research
Description
Description
We encountered an incident of losing all replicas in a shard during a roll, which led to query failures (or partial data returned when skip_unavailable_shards was enabled). Here's a detailed breakdown of the events:
- A deployment updated the ClickHouse Operator (CHOP) with a config change.
- CHOP began rolling the CHI:
chi-foo-1. - It successfully rolled
chi-foo-1-0-0-0and moved on tochi-foo-1-0-1-0. chi-foo-1-0-1-0was brought down as part of the roll.- A Kubernetes node drain event occurred, causing CHOP to be rescheduled to a new node.
- CHOP re-evaluated the CHI and decided to restart the roll.
- It began rolling
chi-foo-1-0-0-0again, even thoughchi-foo-1-0-1-0was still down. - As a result, both replicas were temporarily unavailable.
- During this window, ClickHouse queries either failed or returned partial results due to both replicas being down.
- Once
chi-foo-1-0-0-0came back online, queries recovered. - CHOP then brought up
chi-foo-1-0-1-0.
Expected Behavior
- CHOP should ensure at least one replica remains available during a CHI roll, even if it is rescheduled or interrupted.
- CHOP should try to bring the cluster back to a steady state before proceeding with the rollout of a new configuration—specifically, it should bring up all missing replicas from the previous state before continuing to roll out the new version.
Environment
- CHOP version: 0.24.2
- ClickHouse version: 25.3
Questions
We would appreciate guidance on how this situation could be handled more gracefully by CHOP. Specifically:
- Is there a recommended mechanism to ensure the cluster reaches a steady state before continuing with a rollout?
- Could CHOP implement safeguards to prevent simultaneous downtime of all replicas, particularly in scenarios involving operator rescheduling or external interruptions like node drains?
- Are there any existing patterns or features we could leverage to enforce this behavior today?
We’re potentially interested in contributing a fix or enhancement for this issue. If the maintainers agree that improving this behavior makes sense, we’d be happy to discuss possible approaches or take on an implementation with some guidance.
Metadata
Metadata
Assignees
Labels
bugplannedThis functionality is planned for implementationresearch requiredThis issue requires additional research
Activity
sunsingerus commentedon Feb 19, 2026
Thank you for the detailed incident report — this is a real and well-understood gap in the operator's rolling reconciliation logic. We've confirmed the root cause in the code.
What is happening
There are two separate gaps that combine to produce this incident:
Gap 1 — No steady-state recovery on operator restart
When the operator restarts, it uses generation equality to decide whether to reconcile:
isCleanRestart()returnstrue→ reconciliation is skipped entirelyisGenerationTheSame()returnstrue→ reconciliation is also skippedIn both cases the operator considers the cluster to already be in the desired state, even if a host is actually stuck mid-roll and still down. There is no "are all hosts actually healthy?" health check on startup.
Gap 2 — No pre-exclusion shard health check
shouldExcludeHost()(worker-wait-exclude-include-restart.go) only decides whether the current host needs to be rolled — it never checks whether other replicas in the same shard are currently healthy. So when reconciliation restarts fromhost-0-0whilehost-0-1is still down, nothing prevents excludinghost-0-0and causing simultaneous downtime of all replicas.Failure paths
Depending on timing after the operator reschedule, one of three outcomes occurs:
isCleanRestart()→ skip →host-0-1stays downisGenerationTheSame()→ skip →host-0-1stays downhost-0-0whilehost-0-1still down → both replicas downPlanned fixes
We plan to address this with two complementary changes:
Steady-state health check on startup: On operator restart, before deciding to skip reconciliation, verify that all hosts in the CHI are actually running and healthy. If any host is down or in a degraded state, trigger a targeted recovery reconcile rather than skipping.
Pre-exclusion shard quorum check: Before excluding a host for rolling, verify that all other replicas in the same shard are currently up and ready. If another replica is already down, block the exclusion until the shard reaches a healthy state.
If you'd like to contribute
We welcome contributions on this. The two key files to modify are:
pkg/controller/chi/worker-status-helpers.go—isCleanRestart()/isGenerationTheSame()— add a post-restart health sweeppkg/controller/chi/worker-wait-exclude-include-restart.go—shouldExcludeHost()— add shard quorum check before excludingPlease open a draft PR and we can discuss the approach before full implementation.
rework: shard-safety deferral must not starve sibling shards
Merge shard-safety rework: protect the last healthy replica without s…
alex-zaitsev commentedon Aug 12, 2026
Fixed in https://github.com/Altinity/clickhouse-operator/releases/tag/release-0.27.3
Reconcile unhealthy replicas in the shard prior to healthy ones. Solves