public inbox for [email protected]
help / color / mirror / Atom feedFrom: shveta malik <[email protected]>
To: 南拓弥 <[email protected]>
Cc: [email protected]
Cc: shveta malik <[email protected]>
Subject: Re: Warn on missing replica identity in CREATE/ALTER PUBLICATION
Date: Wed, 22 Apr 2026 09:03:06 +0530
Message-ID: <CAJpy0uAd2BY_jinMWscfLr11WHra7sxrNc18jKbkhp=4CkAFig@mail.gmail.com> (raw)
In-Reply-To: <CAP6NMUKYgRJ3Z5ThhtXpYYkRBffT=fAStwQ3_1Cab0tREZ=5NQ@mail.gmail.com>
References: <CAP6NMUKYgRJ3Z5ThhtXpYYkRBffT=fAStwQ3_1Cab0tREZ=5NQ@mail.gmail.com>
On Tue, Apr 21, 2026 at 11:06 AM 南拓弥 <[email protected]> wrote:
>
> Hi hackers,
>
> CREATE PUBLICATION silently succeeds even when target tables lack a
> usable replica identity, while the publication publishes UPDATE and/or
> DELETE. The error only surfaces later at replication time:
>
> ERROR: cannot delete from table "foo" because it does not have a
> replica identity and publishes deletes
>
> This gap has caused real production incidents — in one case, a CDC
> pipeline using FOR TABLES IN SCHEMA included a table without a primary
> key, and replication stalled for hours before the cause was found.
>
> I'd like to propose emitting a WARNING at publication creation/alter
> time when this mismatch exists. The check would cover all paths:
>
> - CREATE PUBLICATION ... FOR TABLE / FOR TABLES IN SCHEMA / FOR ALL TABLES
> - ALTER PUBLICATION ... ADD/SET TABLE / ADD/SET TABLES IN SCHEMA
> - ALTER PUBLICATION ... SET (publish = 'update, delete')
>
> The approach I'm considering is a publication-level check that runs
> after the final publication state is known, scanning the effective set
> of published tables via GetIncludedPublicationRelations() /
> GetAllSchemaPublicationRelations() / GetAllPublicationRelations() and
> checking each table's replica identity.
>
> I have a working prototype for the FOR TABLE / ADD TABLE paths. A few
> open questions before I post a full patch:
>
> 1. For FOR ALL TABLES, the check would scan pg_class. Acceptable for
> a DDL operation, or too expensive?
>
> 2. Should we cap the number of warnings when many tables are affected?
>
> 3. Should this be controllable via a GUC, or is a simple WARNING
> sufficient?
>
> Thoughts welcome.
>
Before we dive deeper into this idea, I’d like to highlight that
there’s an ongoing thread addressing a similar issue. The proposed
approach there is to implement a fallback RI in such scenarios to
prevent replication-time errors caused by missing RI. Could you please
review this ([1]) and confirm whether it meets your requirements?
https://www.postgresql.org/message-id/flat/CAEoWx2mMorbMwjKbT4YCsjDyL3r9Mp%2Bz0bbK57VZ%2BOkJTgJQVQ%4...
thanks
Shveta
view thread (5+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Warn on missing replica identity in CREATE/ALTER PUBLICATION
In-Reply-To: <CAJpy0uAd2BY_jinMWscfLr11WHra7sxrNc18jKbkhp=4CkAFig@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox