Recovered replica rejoins the CHI service before it catches up after a lost volume

Aperta
#2,140 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go, kubernetes

Direzione di ricerca

Start with shouldWaitReplicationHost in pkg/controller/chi/worker-wait-exclude-include-restart.go and trace how lost-volume recovery updates status.hostsWithReplicaCaughtUp and the first-host check. Compare those paths with the new-replica wait behavior and related issues #2018 and #2096. Done when recovered replicas with shard peers holding data wait for catch-up before joining the service, including the first host case.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

After a lost-volume recovery, the operator includes the recovered host and labels its pod clickhouse.altinity.com/ready=yes right after the tables are created, so the CHI service sends queries to a replica that is still fetching parts. reconcile.host.wait.replicas.new: yes does not cover this case.

Versions
  • clickhouse-operator 0.25.6; the same logic is in 0.27.4 and master
  • ClickHouse 26.1.12, 1 shard × 3 replicas, StatefulSet provisioner
  • reconcile.host.wait.replicas: {all: no, new: yes, delay: 10}, reconcile.host.drop.replicas.onLostVolume: yes
What happens

shouldWaitReplicationHost in pkg/controller/chi/worker-wait-exclude-include-restart.go takes an early exit for a recovered host in both of these cases:

  • A host other than the first: its StatefulSet already exists, so the host is not ObjectStatusCreated. The check then finds the host in status.hostsWithReplicaCaughtUp, written before the volume was lost, and logs Replica is already listed as caught, no need to catch-up again.
  • The first host in the cluster: IsFirstInCluster() returns before any wait.replicas setting is read, so not even all: yes makes it wait.

We replaced the volumes of all three replicas one at a time. Replicas 0-2 and 0-1 each joined the service with about 300 GiB of parts still to fetch, and 0-2 answered 44 client queries in the two minutes before we removed the label by hand.

Expected

A host whose volume was lost waits for catch-up the way a new replica does: its entry in hostsWithReplicaCaughtUp is cleared when data loss is detected, and the first-in-cluster exemption does not apply while other replicas of the shard hold the data.

Related
  • #1567: a new replica is added to the service endpoint immediately
  • #2018: opt-in sync gate that clears stale caught-up markers on data-loss paths when enabled
  • #2096: lost-volume recovery of the shard's first host drops nothing
Workaround

Remove the ready label from the recovered pod each time it is set, and add it back once system.replicas shows the copies equal.

Lingua principale
Go
Stelle
2.6k
Fork
584
Merge medio
4g 11h
PR unite (30g)
15

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Altinity/clickhouse-operator

Tutte le issue di Altinity/clickhouse-operator

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.