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

オープン
#2,140 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go, kubernetes

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Go
スター
2.6k
フォーク
588
平均マージ
4日 5時間
マージ済み PR(30日)
16

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Altinity/clickhouse-operator のほかの issue

Altinity/clickhouse-operator の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。