RE: Fix logical decoding not track transaction during SNAPBUILD_BUILDING_SNAPSHOT

From: ocean_li_996 <ocean_li_996(at)163(dot)com>
To: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "cca5507(at)qq(dot)com" <cca5507(at)qq(dot)com>
Subject: RE: Fix logical decoding not track transaction during SNAPBUILD_BUILDING_SNAPSHOT
Date: 2026-01-28 18:52:27
Message-ID: 7f9e2358.9b73.19c05f3296f.Coremail.ocean_li_996@163.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Hayato,

At 2026-01-27 10:17:26, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
>Sorry, can you evaluate bit more why the 0003 patch is enough for the fix? E.g.,
>apart from 0001, 0003 adds invalidation message to the transaction (or immediately

>invalidate) even if we do not have the consistent snapshot yet.

Yeah. IIUC, the 0003 patch can fix this issue.

The 0003 patch involves the least amount of code changes, but the trade‑off is that
it adds extra computation and memory usage, which may affect efficiency. This is because,
during the transition from SNAPBUILD_BUILDING_SNAPSHOT to SNAPBUILD_FULL_SNAPSHOT, useless
XIDs (see the definition of useless XIDs in the 0004 patch) will be added to the reorder buffer.

The regular changes of these useless‑XID transactions will not be added to the reorder buffer
(see SnapBuildProcessChange). Invalidation messages with a useless XID will be added to the
reorder buffer, but will not be processed, because the transaction does not yet have a base
snapshot (see ReorderBufferForget). As for invalidation messages without an XID, they will still
be executed, but this will not cause correctness issues, since we are still in a state where
changes cannot be decoded.

Regards
Haiyang Li

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message ocean_li_996 2026-01-28 18:57:25 Re:RE: Fix logical decoding not track transaction during SNAPBUILD_BUILDING_SNAPSHOT
Previous Message Andrey Borodin 2026-01-28 18:09:35 Re: pgsql: Prevent invalidation of newly synced replication slots.