Re: Non-replayable WAL records through overflows and >MaxAllocSize lengths - Mailing list pgsql-hackers

From Matthias van de Meent
Subject Re: Non-replayable WAL records through overflows and >MaxAllocSize lengths
Date
Msg-id CAEze2Wg2eOQjddyB=+Nh=Jk45iDjNqLoT2Xn_XQn6y0F08RioQ@mail.gmail.com
Whole thread Raw
In response to Re: Non-replayable WAL records through overflows and >MaxAllocSize lengths  (Michael Paquier <michael@paquier.xyz>)
Responses Re: Non-replayable WAL records through overflows and >MaxAllocSize lengths
List pgsql-hackers
On Tue, 21 Jun 2022 at 03:45, Michael Paquier <michael@paquier.xyz> wrote:
> +   /*
> +    * Ensure that xlogreader.c can read the record by ensuring that the
> +    * data section of the WAL record can be allocated.
> +    */
> +   if (unlikely(!AllocSizeIsValid(total_len)))
> +       XLogErrorDataLimitExceeded();
>
> By the way, while skimming through the patch, the WAL reader seems to
> be a bit more pessimistic than this estimation, calculating the amount
> to allocate as of DecodeXLogRecordRequiredSpace(), based on the
> xl_tot_len given by a record.

I see, thanks for notifying me about that.

PFA a correction for that issue. It does copy over the value for
MaxAllocSize from memutils.h into xlogreader.h, because we need that
value in FRONTEND builds too, and memutils.h can't be included in
FRONTEND builds. One file suffixed with .backpatch that doesn't
include the function signature changes, but it is not optimized for
any stable branch[15].

-Matthias

PS. I'm not amused by the double copy we do in the xlogreader, as I
had expected we'd just read the record and point into that single
xl_rec_len-sized buffer. Apparently that's not how it works...

[15] it should apply to stable branches all the way back to
REL_15_STABLE and still work as expected. Any older than that I
haven't tested, but probably only require some updates for
XLogRecMaxLength in xlogreader.h.

Attachment

pgsql-hackers by date:

Previous
From: Jacob Champion
Date:
Subject: [Commitfest 2022-07] Begins Now
Next
From: "David G. Johnston"
Date:
Subject: Re: doc: Clarify what "excluded" represents for INSERT ON CONFLICT