pg_receivewal: Skip LZ4-compressed segments with incomplete frames

When searching for the latest WAL segment to determine where to start
streaming, pg_receivewal decompresses each completed LZ4 segment and
accepts it if the segment matches the expected size.  The code did not
check that the LZ4 frame was complete, so a slightly-truncated segment,
or a segment compressed with content checksum (we support the case of
segments compressed by external tools) with an incorrect checksum, could
be considered as valid while it is not.

These segments are now skipped when trying to find the LSN where
streaming should start, if found, so as we are more proactive in
detecting if something is wrong with the WAL records (aka this is faster
than waiting for replay and a CRC32 failure in a WAL record).

Oversight in babbbb595d23.

Author: Raja Sai Pranav <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 15

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/359defb5f233eee7491f4e8b5fe76b82169715f2

Modified Files
--------------
src/bin/pg_basebackup/pg_receivewal.c | 11 +++++++++++
1 file changed, 11 insertions(+)

Reply via email to