| From: | "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com> |
|---|---|
| To: | vignesh C <vignesh21(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | RE: Publication DDL can race with a concurrent UPDATE |
| Date: | 2026-09-08 05:24:25 |
| Message-ID: | TY4PR01MB17718FD116A2C749F35D28FD094B12@TY4PR01MB17718.jpnprd01.prod.outlook.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Monday, September 7, 2026 8:56 PM vignesh C <vignesh21(at)gmail(dot)com> wrote:
>
> The underlying issue appears to be that publication DDL naming a table takes
> ShareUpdateExclusiveLock, which does not conflict with the
> RowExclusiveLock held by a concurrent UPDATE. This allows the publication
> definition to change while the UPDATE is in progress: the UPDATE uses the old
> definition when checking the operation and generating WAL, while logical
> decoding uses the new definition.
Thanks for reporting the issue.
>
> There may be other variations of this race ex: adding column list, but the
> underlying problem is the same: an UPDATE can proceed based on stale
> publication information and produce a logical replication change that is
> rejected only later on the subscriber.
>
> I fixed the issue by changing the lock taken by publication DDL from
> ShareUpdateExclusiveLock to ShareRowExclusiveLock. This makes the DDL
> conflict with the RowExclusiveLock held by concurrent data-modifying
> statements, preventing the publication definition from changing while the
> UPDATE is in progress.
I think this fix is not sufficient, as it does not address the ALTER PUBLICATION
SET (options) cases, where the publication action can also be altered
concurrently with DMLs, IIUC. The publication data in the relcache is also
affected by pubaction changes, so those should be blocked as well.
Addressing the above should be sufficient for the row filter and column list
cases. However, for the replica identity check on UPDATE and DELETE operations,
further analysis may be needed - especially for the TABLES IN SCHEMA and ALL
TABLES cases, where tables are not explicitly published.
> [1] - https://www.postgresql.org/message-
> id/CAOzEurQaGBrDu8hFw%2Bp16_uf_%2Bb94A276fYgzwUOK5X-
> bSX%2Bjg%40mail.gmail.com
Best Regards,
Zhijie Hou
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tatsuo Ishii | 2026-09-08 05:54:31 | Re: Row pattern recognition |
| Previous Message | shveta malik | 2026-09-08 05:12:54 | Re: Crashes on a partition whose concurrent detach never finished |