| From: | Peter Geoghegan <pg(at)bowt(dot)ie> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Export subxip[] for snapshots taken during recovery. |
| Date: | 2026-08-26 19:38:33 |
| Message-ID: | E1wzJSC-00000002EZ2-2PIs@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Export subxip[] for snapshots taken during recovery.
A snapshot taken during recovery stores all of its in-progress XIDs in
subxip, every running top-level XID included, leaving xip empty. Unlike
with other snapshots, its suboverflowed flag does not mean that subxip
is redundant. We nevertheless treated it that way during snapshot
export, so an importing session could see in-progress transactions as
aborted. This misbehavior could also lead to hint bits being
incorrectly set on the standby; affected tuples then wrongly appeared
visible or invisible to sessions that never imported the snapshot.
To fix, teach snapshot export to include the subxip[] array regardless
of the overflow flag when the snapshot is taken during recovery. This
is in line with how CopySnapshot() and SerializeSnapshot() already
handle the same issue.
Claude Code diagnosed this problem. The committed TAP test is a
simplified version of the one that it wrote to demonstrate this bug.
Oversight in commit 6c2003f8a, which enabled snapshot export and import
during recovery.
Author: Peter Geoghegan <pg(at)bowt(dot)ie>
Author: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Bug: #17846
Discussion: https://postgr.es/m/CAH2-WzmHVeYY%3Dpjz9x8DhhxVjXHX0pvoQ-MdiB1Tt6%3Do2GTiKg%40mail.gmail.com
Discussion: https://postgr.es/m/17846-1a0e5ce976f4c01a@postgresql.org
Backpatch-through: 14
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/74c9832ca61037eec25b8f214fc71883494900d8
Modified Files
--------------
src/backend/utils/time/snapmgr.c | 58 ++++++++----
src/test/recovery/meson.build | 1 +
src/test/recovery/t/056_standby_snapshot_export.pl | 104 +++++++++++++++++++++
3 files changed, 147 insertions(+), 16 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrew Dunstan | 2026-08-26 20:25:46 | pgsql: Pin two ctype-dependent test_regex_utf8 cases to pg_c_utf8 |
| Previous Message | Masahiko Sawada | 2026-08-26 19:06:11 | pgsql: Fix crash in subscription refresh on concurrent relation drop. |