pgsql: Report detailed errors from XLogFindNextRecord() failures.

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Report detailed errors from XLogFindNextRecord() failures.
Date: 2026-03-24 13:34:04
Message-ID: E1w51tT-001F1E-1o@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Report detailed errors from XLogFindNextRecord() failures.

Previously, XLogFindNextRecord() did not return detailed error information
when it failed to find a valid WAL record. As a result, callers such as
the WAL summarizer, pg_waldump, and pg_walinspect could only report generic
errors (e.g., "could not find a valid record after ..."), making
troubleshooting difficult.

This commit fix the issue by extending XLogFindNextRecord() to return
detailed error information on failure, and updating its callers to include
those details in their error messages.

For example, when pg_waldump is run on a WAL file with an invalid magic number,
it now reports not only the generic error but also the specific cause
(e.g., "invalid magic number").

Author: Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com>
Reviewed-by: Mircea Cadariu <cadariu(dot)mircea(at)gmail(dot)com>
Reviewed-by: Japin Li <japinli(at)hotmail(dot)com>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAO6_XqoxJXddcT4wkd9Xd+cD6Sz-fyspRGuV4Bq-wbXG4pVNzA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1c162c965a113192cd5137e6de38a10fbc0a5692

Modified Files
--------------
contrib/pg_walinspect/pg_walinspect.c | 16 ++++++++++++----
src/backend/access/transam/xlogreader.c | 24 +++++++++++++++++++++---
src/backend/postmaster/walsummarizer.c | 17 ++++++++++++-----
src/bin/pg_waldump/pg_waldump.c | 12 +++++++++---
src/bin/pg_waldump/t/001_basic.pl | 28 ++++++++++++++++++++++++++++
src/include/access/xlogreader.h | 3 ++-
6 files changed, 84 insertions(+), 16 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2026-03-24 13:36:49 pgsql: Fix accidentally casting away const
Previous Message Robert Haas 2026-03-24 13:05:09 pgsql: Bounds-check access to TupleDescAttr with an Assert.