Stream sync generates an empty `FOR TABLE` clause for a standalone Patroni slot

Open Beginner friendly
#3,252 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go, kubernetes, postgresql
Domain
backend, databases

Research direction

Start in pkg/cluster/streams.go at the stream sync logic around the linked lines 125–140 and 380–422; trace how standalone Patroni slots reach publication creation. Check the existing behavior described in PR #2868 and the SQL execution path in pkg/cluster/database.go. Done when an empty table map with no existing publication keeps the slot in slotsToSync and skips CREATE PUBLICATION.

Written by the indexing model from the issue text.

Description

Description

When a cluster uses event streams, it can also define a logical replication slot in spec.patroni.slots for a separate consumer. If no stream supplies tables for that slot and no publication with the same name exists, the operator adds the slot with an empty table map and queues a CREATE PUBLICATION statement with an empty table list. PostgreSQL rejects the generated SQL on every sync.

Steps to reproduce

  1. Install the FabricEventStream CRD and configure a postgresql resource with an active entry in spec.streams.
  2. Add a separate logical replication slot in spec.patroni.slots (for example my_custom_slot: {type: logical, database: foo, plugin: pgoutput}) in database foo without an existing publication named my_custom_slot.
  3. During stream sync, the operator executes:
CREATE PUBLICATION "my_custom_slot" FOR TABLE  WITH (publish = 'insert, update');

Observed behavior

PostgreSQL rejects the statement with ERROR: syntax error at or near "WITH" (SQLSTATE 42601), and the operator logs a publication creation error on every reconcile.

Expected behavior

When a slot in spec.patroni.slots has no stream tables (len(newTables) == 0) and no existing publication, stream sync should keep the slot in slotsToSync and skip CREATE PUBLICATION. (PR #2868 preserves an existing publication for a standalone slot, whereas this case starts with no publication.)

Dominant language
Go
Stars
5.3k
Forks
1.1k
Avg merge
3d 17h
Merged PRs (30d)
11

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from zalando/postgres-operator

All issues in zalando/postgres-operator

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.