Re: Race conditions in logical decoding

From: Noah Misch <noah(at)leadboat(dot)com>
To: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Antonin Houska <ah(at)cybertec(dot)at>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Mihail Nikalayeu <mihailnikalayeu(at)gmail(dot)com>
Subject: Re: Race conditions in logical decoding
Date: 2026-09-10 23:49:11
Message-ID: 20260910234911.58.noahmisch@microsoft.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jan 19, 2026 at 05:29:25PM +0100, Antonin Houska wrote:
> A stress test [1] for the REPACK patch [1] revealed data
> corruption. Eventually I found out that the problem is in postgres core. In
> particular, it can happen that a COMMIT record is decoded, but before the
> commit could be recorded in CLOG, a snapshot that takes the commit into
> account is created and even used. Visibility checks then work incorrectly
> until the CLOG gets updated.

On Fri, Aug 21, 2026 at 08:16:02PM +0200, Álvaro Herrera wrote:
> So, what do you think of the attached?

I see $SUBJECT lost open item status because released versions have the same
defect. However, REPACK (CONCURRENTLY) increases the importance of $SUBJECT
and other logical replication data loss causes. In v18, one can recreate the
replica or run integrity checks before a cutover. REPACK (CONCURRENTLY)
automates the chain: one command starts replication, waits for consistency,
and deletes the last known good copy.

If v19 ships without a fix for $SUBJECT, I think REPACK (CONCURRENTLY) docs
need to warn about the situation. How do you see it?

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2026-09-10 23:59:08 Re: pg_get_*_ddl() needs a redesign
Previous Message Tom Lane 2026-09-10 23:46:50 Re: Add PRODUCT() aggregate function