[patch] Make "invalid record length at <LSN>: expected at least 24, got 0" message less scary

From: Michael Banck <mbanck(at)gmx(dot)net>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: [patch] Make "invalid record length at <LSN>: expected at least 24, got 0" message less scary
Date: 2024-11-30 11:41:15
Message-ID: 674af9dc.050a0220.268e1c.4048@mx.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

we had another case on irc today were a user saw Postgres doing crash
recovery due to an unclean shutdown and was very worried about a
"invalid record length at <LSN>: expected at least 24, got 0" message
and went on to reindex all databases. This is also a frequent hit on
Stack Overflow etc.

AFAICT this is a normal message in case the record length is 0 and we
have reached end of WAL. So I propose to treat a length of 0 as a
special case and emit a less-scary message. Up until 9.4 we did have a
message "record with zero length at <LSN>", but 2c03216d831 ("Revamp the
WAL record format") removed it. I propose to reinstate it, see attached
patch.

I guess it would be even nicer if we could hint here that we likely
reached end-of-WAL, but the helper function report_invalid_record() does
not take an errhint and I guess we are too deep into the WAL reader
machinery to check for an end-of-WAL condition at that spot.

Michael

Attachment Content-Type Size
v1-0001-Re-introduce-less-scary-message-for-possible-end-.patch text/x-diff 1.7 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Junwang Zhao 2024-11-30 11:54:35 Re: Unclear code - please elaborate
Previous Message Kirill Gavrilov 2024-11-30 08:44:00 Re: Truncate logs by max_log_size