Stream sync continues after Patroni config failures and loses slot deletion retries

未关闭
#3,255 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go, kubernetes, postgresql
领域
backend, databases

调研方向

Start with the referenced synchronization paths in pkg/cluster/streams.go (around lines 169-175 and 430-462) and pkg/cluster/sync.go (around lines 967-1047). Trace how Patroni errors affect stream resource creation and how slot deletions are tracked, then inspect the related reconciliation tests. Done means failed slot configuration prevents stream updates, and deletion retries succeed after Patroni recovers.

由索引模型根据 Issue 内容生成。

描述

Description

When stream synchronization cannot apply logical replication slots through Patroni, the operator still creates or updates FabricEventStream resources and reports the sync as successful. The generated resource can reference a PostgreSQL replication slot that was not created.

Failed slot deletions are also not retried. After a stream is removed, the PostgreSQL publication and FabricEventStream disappear, but the corresponding logical replication slot remains in PostgreSQL and Patroni after a later reconciliation. The same behavior occurs when deleting an explicit spec.patroni.slots entry and Patroni returns an error for PATCH /config.

These states can expose unusable stream configuration to consumers and leave logical replication slots retaining WAL indefinitely.

Relevant code:

Environment

  • Operator: ghcr.io/zalando/postgres-operator:v2.0.3
  • Kubernetes: v1.33.1 on kind v0.29.0
  • Spilo: ghcr.io/zalando/spilo-18:4.1-p2
  • PostgreSQL: 18.3
  • Patroni: 4.1.0
  • Platform: local kind cluster on Linux
  • Production: no, isolated reproduction
  • Operator source: 61e4c9fa7ad37f1d4891a4b9ac99aec7b42c46d4

Steps to reproduce

Case 1: Create a stream while Patroni is unavailable
  1. Install the FabricEventStream CRD and create a one-instance PostgreSQL cluster with database foo.
  2. Configure a stream for foo.public.outbox and wait until its publication and logical slot are healthy.
  3. Pause the Patroni process with SIGSTOP, leaving PostgreSQL running.
  4. Add a second stream with application ID second-app.
  5. Wait for reconciliation and inspect the resulting FabricEventStream, PostgreSQL publications, and replication slots.
Case 2: Remove a healthy stream while Patroni is unavailable
  1. Start with a healthy stream whose publication, FabricEventStream, PostgreSQL slot, and Patroni slot all exist.
  2. Pause Patroni with SIGSTOP.
  3. Remove the stream from the PostgreSQL resource.
  4. Wait for the FabricEventStream and publication to be deleted.
  5. Resume Patroni and trigger another reconciliation without restoring the stream.

The same deletion failure can be reproduced for an explicit slot under spec.patroni.slots: make Patroni reject PATCH /config, remove the slot from the PostgreSQL resource, restore Patroni, and reconcile again.

Observed behavior

For Case 1, the operator logs a Patroni GET /config timeout and then creates the FabricEventStream:

acid-stream-repro-xw1xw second-app fes_foo_second_app
publication_count|1
slot_count|0

The generated resource references fes_foo_second_app, but PostgreSQL does not contain that slot.

For Case 2, the first reconciliation completes the publication and CR cleanup but leaves the slot:

fes_count|0
publication_count|0
slot_count|1

After Patroni is resumed and reconciliation runs again, the slot is still present:

publication_count|0
slot_count|1
patroni_slot|{"database":"foo","plugin":"pgoutput","type":"logical"}
fes_count|0

For an explicit slot, Patroni returned HTTP 409 for {"slots":{"manual_repro":null}}. After access was restored and another reconciliation completed, manual_repro remained in both PostgreSQL and Patroni.

Expected behavior

  • Do not create or update a FabricEventStream until all required Patroni slot configuration has been applied successfully.
  • Return or retry the failed synchronization instead of reporting success.
  • Retain pending slot deletions until Patroni confirms the deletion, including across later reconciliations.
  • Remove the slot from PostgreSQL and Patroni after access recovers without requiring the user to restore and remove the stream again.
主要语言
Go
星标
5.3k
派生
1.1k
平均合并
3 天 17 小时
30 天内合并 PR
11

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

zalando/postgres-operator 的其他 Issue

查看 zalando/postgres-operator 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。