From 72ac1113ed66ab1b880a8cd4b43fd5a4463f96d1 Mon Sep 17 00:00:00 2001 From: kaffa Date: Thu, 11 Jun 2026 07:29:24 +0900 Subject: [PATCH] =?UTF-8?q?history:=202026-06-11=20kr2=20k3s=208h=20hang?= =?UTF-8?q?=20=EC=9D=B8=EC=8B=9C=EB=8D=98=ED=8A=B8=20(Patroni=20failover?= =?UTF-8?q?=20=ED=9B=84=20read-only=20DB=EB=A1=9C=20kine=20wedge,=20kill+r?= =?UTF-8?q?estart=20=EB=B3=B5=EA=B5=AC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- history/2026-06-11-kr2-k3s-readonly-hang.md | 43 +++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 history/2026-06-11-kr2-k3s-readonly-hang.md diff --git a/history/2026-06-11-kr2-k3s-readonly-hang.md b/history/2026-06-11-kr2-k3s-readonly-hang.md new file mode 100644 index 0000000..02cb09d --- /dev/null +++ b/history/2026-06-11-kr2-k3s-readonly-hang.md @@ -0,0 +1,43 @@ +--- +date: 2026-06-11 +topic: kr2 K3s control-plane 8h hang — Patroni failover 후 read-only DB로 kine 기동 wedge +areas: + - infra/compute/hosts/incus-kr2.md + - infra/data/postgresql-ha.md +tags: [history, incident, k3s, patroni, kine, postgresql] +--- + +K3s 점검 중 발견. incus-kr2 control-plane의 k3s.service가 2026-06-10 22:55부터 약 8시간 `activating` 상태로 멈춰 kr3 컨텍스트 API(100.119.109.41:6443) connection refused. + +## 원인 체인 + +1. 2026-06-10 22:55경 **Patroni failover** 발생 (leader → postgres-2 / 10.100.3.185, incus-kr1). 전환 윈도우 동안 3개 Postgres 노드가 모두 read-only. +2. 마침 그 시점에 kr2 k3s가 (재)기동 중이었고, kine(pgx)이 설정된 노드 IP 3개(10.100.2.5 / 10.100.3.185 / 10.100.1.83)에 직접 연결 시도 → 전부 `ValidateConnect failed: read only connection`. +3. k3s가 `Configuring pgx database connection pooling` 로그 직후 **프로세스 hang** (PID 3580986, STAT=Ssl). 8시간 동안 추가 로그 0, SIGTERM 무시(systemd `deactivating`에서 대기). +4. Patroni는 이후 정상 회복(leader 선출 완료)됐지만 kr2 k3s는 자가복구 못 하고 wedge 유지. + +## 영향 + +- 클러스터는 **kr1 control-plane으로 계속 서빙**(`/healthz` ok)되어 외부 영향 제한적. kr2만 API/스케줄 제외. +- 동반: `apisix/apisix-etcd-1`(kr1) 같은 22:55 이벤트로 etcd raft `commitTo` panic → CrashLoopBackOff. etcd quorum 2/3(hp1/hp2) 유지로 APISIX는 동작. → 씬(syn) 도메인, 별도 remediation 필요. + +## 복구 + +```bash +ssh kaffa@100.119.109.41 # incus-kr2 +sudo kill -9 3580986 # hang된 k3s PID 강제 종료 (SIGTERM 무시함) +sudo systemctl start k3s # 재기동 → 정상 leader(postgres-2)에 연결, 합류 +``` +- 복구 후 4노드 전부 Ready (kr1/kr2 control-plane, hp1/hp2 worker, v1.34.7+k3s1). + +## 재발 패턴 / 교훈 + +- **동일 패턴 재발**: [[2026-05-23-kr1-k3s-stuck-cascade]] (kr1 12h stuck), [[2026-04-08-patroni-failover-incident]] (read-only 직결 참조 사고)와 같은 계열. +- 근본: kine이 **노드 IP 직결**(read-write 윈도우 의존) + k3s가 기동 시점 all-read-only면 **deadlock/hang**해 자가복구 못 함. +- 개선 후보: + 1. kr2(및 kr1) k3s의 kine 연결을 노드 IP 직결 → **OpenWrt HAProxy(192.168.9.1:5432, leader 라우팅)** 경유로 변경 (2026-04-08 교훈과 동일 방향). + 2. k3s.service에 watchdog/healthcheck(`Restart=on-failure` + 기동 실패 감지) 보강 — 현재 hang은 Restart로 안 잡힘(프로세스가 살아있는 채 멈춤). + 3. Patroni failover 빈도 자체 점검 (왜 22:55에 전환됐는지 — etcd DCS 안정성). + +## 참조 +- [[../infra/data/postgresql-ha|postgresql-ha]] · [[../infra/compute/hosts/incus-kr2|incus-kr2]]