pgsql: Fix incorrect LSNs in WAL decoding error messages

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix incorrect LSNs in WAL decoding error messages
Date: 2026-11-03 01:54:53
Message-ID: E1xO3jh-00000001sam-2hSf@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix incorrect LSNs in WAL decoding error messages

Commit 3f1ce97346 introduced a circular WAL decoding buffer,
allowing records to be decoded before they are consumed. However,
decoding error messages continued to report the location of the last
record consumed instead of the record that failed decoding. With
recovery prefetching, the reported location could be many records
behind the failing record, making WAL problems harder to diagnose.

Fix this by reporting the location of the record being decoded.
Errors now identify the failing record even with recovery prefetching,
making it easier to investigate malformed WAL during recovery or with
tools such as pg_waldump and pg_walinspect.

Backpatch to v15, where the WAL decoding buffer was introduced.

Author: Rahul Yadav <rahul(at)rhyadav(dot)dev>
Reviewed-by: Surya Poondla <suryapoondla4(at)gmail(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/P2qIkq4--F-9@rhyadav.dev
Backpatch-through: 15

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3ec98353523b98c47a0b901ea43b25e7fe55eb17

Modified Files
--------------
src/backend/access/transam/xlogreader.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2026-11-03 04:05:44 pgsql: Reject incremental backups based on a backup from a divergent hi
Previous Message Fujii Masao 2026-11-03 01:54:33 pgsql: Fix incorrect LSNs in WAL decoding error messages