Propagate XLogFindNextRecord error to callers

From: Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Propagate XLogFindNextRecord error to callers
Date: 2025-12-12 10:39:50
Message-ID: CAO6_XqoxJXddcT4wkd9Xd+cD6Sz-fyspRGuV4Bq-wbXG4pVNzA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Currently, XLogFindNextRecord errormsg is ignored and callers will only
output a generic 'could not find a valid record' message without details.
Additionally, invalid page header won't go through XLogReadRecord, leaving
the error in state->errormsg_buf.

This patch propagates XLogFindNextRecord's error message to the callers and
displays it. In case of an invalid page header, the errormsg is filled with
errormsg_buf content.

With this patch, pg_waldump will now have the following output when reading
a file with an invalid header:
pg_waldump: error: could not find a valid record after D80/5C000000:
invalid magic number D116 in WAL segment 0000001400000D8000000017, LSN
D80/5C000000, offset 0

Regards,
Anthonin Bonnefoy

Attachment Content-Type Size
v1-0001-Propage-errormsg-to-XLogFindNextRecord-caller.patch application/octet-stream 6.9 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Akshay Joshi 2025-12-12 10:52:55 Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement
Previous Message Daniel Gustafsson 2025-12-12 10:29:27 Re: Fix memory leak in gist_page_items() of pageinspect