Skip to content

fix(instance): skip standby-prep when PRIMARY_ENDPOINT is self (crashloop fix)#278

Merged
KeiaiLab-PHIL merged 1 commit into
mainfrom
fix/instance-skip-standby-when-self-primary
Jun 23, 2026
Merged

fix(instance): skip standby-prep when PRIMARY_ENDPOINT is self (crashloop fix)#278
KeiaiLab-PHIL merged 1 commit into
mainfrom
fix/instance-skip-standby-when-self-primary

Conversation

@KeiaiLab-PHIL

Copy link
Copy Markdown
Contributor

Root cause (postgres-prod 7-day outage live blocker)

operator status가 죽은 옛 primary(shard-0-1)를 primary로 stale 인식 → PRIMARY_ENDPOINT=죽은-노드 주입 → 모든 노드가 PrepareRestartedPrimaryAsStandbyWithRewind에서 죽은 노드로 pg_rewind 시도 → DNS/connection 실패 → 무한 crashloop. 실제 데이터 primary(0-0)조차 marker(.keiailab-restart-primary-as-standby)가 남아 자기를 standby화하려다 self-rewind connection refused crashloop.

라이브 복구는 PGDATA의 marker + standby.signal 수동 제거로만 가능했다 (데이터는 "in production" 무손상).

Fix

RejoinOptions.SelfEndpoint 추가 → PrimaryEndpoint == SelfEndpoint면 operator가 본 노드를 primary로 지정한 것이므로 standby-prep을 skip하고 marker를 제거(primary로 부팅). 수동 복구를 코드 자동화.

Verify

go build/vet ok
회귀테스트 TestPrepareRestartedPrimaryAsStandby_SelfPrimarySkips PASS (marker 제거 + standby.signal 미생성 + prepared=false)
기존 standby 테스트 전부 PASS

라이브: 본 fix를 빌드한 pg 이미지 배포 시, failover로 PRIMARY_ENDPOINT가 자기 자신이 된 노드는 standby화 시도 없이 primary 부팅 → 7일 다운 재발 불가.

관련 INC 체인: postmaster.pid(#276) + RBAC pods delete(#277) + reseed(#205/#220) + 본 self-primary guard.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

…ashloop 차단)

INC-2026-06-23 postgres-prod 7일 다운 라이브 차단점: operator status가 죽은 옛 primary(shard-0-1)를 primary로 stale 인식 → PRIMARY_ENDPOINT=죽은노드 → 모든 노드가 PrepareRestartedPrimaryAsStandbyWithRewind 에서 죽은 노드로 pg_rewind 시도 → DNS/connection 실패 무한 crashloop. 실제 primary(0-0)조차 PRIMARY_ENDPOINT(=자기 or 죽은노드) 보고 자기를 standby화하려다 self-rewind connection-refused crashloop.

Fix: RejoinOptions.SelfEndpoint 추가 + PrimaryEndpoint==SelfEndpoint면 operator가 본 노드를 primary로 지정한 것이므로 standby화 skip + marker 제거. 라이브에서 수동 marker(.keiailab-restart-primary-as-standby)+standby.signal 제거로만 복구되던 것을 코드 자동화. 회귀테스트 TestPrepareRestartedPrimaryAsStandby_SelfPrimarySkips PASS, go build/vet/test ok.

관련: #205/#220 reseed + postmaster.pid(#276) + RBAC(#277) 동일 INC 체인의 라이브 차단점 최종 fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@KeiaiLab-PHIL KeiaiLab-PHIL merged commit ce78982 into main Jun 23, 2026
@KeiaiLab-PHIL KeiaiLab-PHIL deleted the fix/instance-skip-standby-when-self-primary branch June 23, 2026 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant