Re: Non-replayable WAL records through overflows and >MaxAllocSize lengths
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Matthias van de Meent <boekewurm+postgres@gmail.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>, Andres Freund <andres@anarazel.de>, Ian Lawrence Barwick <barwick@gmail.com>, Heikki Linnakangas <hlinnaka@iki.fi>, David Zhang <david.zhang@highgo.ca>, Robert Haas <robertmhaas@gmail.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2023-04-09T23:31:21Z
Lists: pgsql-hackers
On Sat, Apr 08, 2023 at 04:24:35PM +0200, Matthias van de Meent wrote: > Thanks a lot! I'll post the separation of record construction and > write-out to xlog in a future thread for 17. Thanks! Creating a new thread makes sense. > One remaining question: Considering that the changes and checks of > that commit are mostly internal to xloginsert.c (or xlog.c in older > releases), and that no special public-facing changes were made, would > it be safe to backport this to older releases? The routine changes done in ffd1b6b cannot be backpatched on ABI grounds, still you would propose to have protection around needs_data as well as the whole record length. > PostgreSQL 15 specifically would benefit from this as it supports > external rmgrs which may generate WAL records and would benefit from > these additional checks, but all supported releases of PostgreSQL have > pg_logical_emit_message and are thus easily subject to the issue of > writing oversized WAL records and subsequent recovery- and replication > stream failures. Custom RMGRs are a good argument, though I don't really see an urgent argument about doing something in REL_15_STABLE. For one, it would mean more backpatching conflicts with ~14. Another argument is that XLogRecordMaxSize is not an exact science, either. In ~15, a record with a total size between XLogRecordMaxSize and DecodeXLogRecordRequiredSpace(MaxAllocSize) would work, though it would not in 16~ because we have the 4MB margin given as room for the per-record allocation in the XLogReader. A record of such a size would not be generated anymore after a minor release update of 15.3~ if we were to do something about that by May on REL_15_STABLE. -- Michael
Commits
-
Add more protections in WAL record APIs against overflows
- 8fcb32db98ed 16.0 landed
-
Add overflow protection for block-related data in WAL records
- ffd1b6bb6f8a 16.0 landed
-
Change internal RelFileNode references to RelFileNumber or RelFileLocator.
- b0a55e43299c 16.0 cited
-
Revamp the WAL record format.
- 2c03216d8311 9.5.0 cited