[PATCH] Perform check for oversized WAL record before calculating record CRC - Mailing list pgsql-hackers

From Sergey Fukanchik
Subject [PATCH] Perform check for oversized WAL record before calculating record CRC
Date
Msg-id db2c6c76-3ff0-484f-9957-11b99732d943@postgrespro.ru
Whole thread Raw
Responses Re: [PATCH] Perform check for oversized WAL record before calculating record CRC
List pgsql-hackers
Hi Postgres hackers,
I found a case where CRC of 1Gb block is calculated first and then 
immediately
discarded.

There is a limit on WAL record size - XLogRecordMaxSize. If the record
being inserted is larger than that, it is discarded and error is reported:

ERROR:  oversized WAL record
DETAIL:  WAL record would be 1069547521 bytes (of maximum 1069547520 bytes)

However, crc of record data is calculated before the record size is 
validated,
and in case of oversized record this crc is not used anywhere.

It is surely a minor issue, but might be worth fixing. I'm proposing a 
patch.
Since this situation is not covered by any tests I also included a test case
for failing on huge WAL records.
---
Sergey Fukanchik

Attachment

pgsql-hackers by date:

Previous
From: Dilip Kumar
Date:
Subject: Re: Proposal: Conflict log history table for Logical Replication
Next
From: Robert Treat
Date:
Subject: Re: postmaster uses more CPU in 18 beta1 with io_method=io_uring