pgsql: Avoid trying to write an empty WAL record in log_newpage_range()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid trying to write an empty WAL record in log_newpage_range()
Date: 2023-04-17 18:22:34
Message-ID: E1poTUn-003ZRT-Gh@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid trying to write an empty WAL record in log_newpage_range().

If the last few pages in the specified range are empty (all zero),
then log_newpage_range() could try to emit an empty WAL record
containing no FPIs. This at least upsets an Assert in
ReserveXLogInsertLocation, and might perhaps have bad real-world
consequences in non-assert builds.

This has been broken since log_newpage_range() was introduced,
but the case was hard if not impossible to hit before commit 3d6a98457
decided it was okay to leave VM and FSM pages intentionally zero.
Nonetheless, it seems prudent to back-patch. log_newpage_range()
was added in v12 but later back-patched, so this affects all
supported branches.

Matthias van de Meent, per report from Justin Pryzby

Discussion: https://postgr.es/m/ZD1daibg4RF50IOj@telsasoft.com

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/72a914e9fb7353e17776a2692fb21cff49725400

Modified Files
--------------
src/backend/access/transam/xloginsert.c | 4 ++++
1 file changed, 4 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Andrew Dunstan 2023-04-17 18:57:27 Re: pgsql: Further cleanup of autoconf output files for GSSAPI changes.
Previous Message Peter Geoghegan 2023-04-17 16:59:10 pgsql: Fix incorrect comment about nbtree WAL record.