pgsql: Report detailed errors from XLogFindNextRecord() failures. - Mailing list pgsql-committers

From Fujii Masao
Subject pgsql: Report detailed errors from XLogFindNextRecord() failures.
Date
Msg-id E1w51tT-001F1E-1o@gemulon.postgresql.org
Whole thread Raw
List 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.bonnefoy@datadoghq.com>
Reviewed-by: Mircea Cadariu <cadariu.mircea@gmail.com>
Reviewed-by: Japin Li <japinli@hotmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.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(-)


pgsql-committers by date:

Previous
From: Robert Haas
Date:
Subject: pgsql: Bounds-check access to TupleDescAttr with an Assert.
Next
From: Peter Eisentraut
Date:
Subject: pgsql: Fix accidentally casting away const