pgsql: pg_basebackup: Fix code that thinks about LZ4 buffer size. - Mailing list pgsql-committers

From Robert Haas
Subject pgsql: pg_basebackup: Fix code that thinks about LZ4 buffer size.
Date
Msg-id E1nbNwy-000IDd-8g@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
pg_basebackup: Fix code that thinks about LZ4 buffer size.

Before this patch, there was some code that tried to make sure that the
buffer was always big enough at the start, and then asserted that it
didn't need to be enlarged later. However, the code to make sure it was
big enough at the start doesn't actually work, and therefore it was
possible to fail an assertion and crash later.

Remove the code that tries to make sure the buffer is always big enough
at the start in favor of enlarging the buffer as we go along whenever
that is necessary.

The mistake probably happened because, on the server side, we do
actually need to guarantee that the buffer is big enough at the start
to avoid subsequent resizings. However, in that case, the calling
code makes promises about how much data it will provide at once, but
here, that's not the case.

Report by Justin Pryzby. Analysis by me. Patch by Dipesh Pandit.

Discussion: http://postgr.es/m/20220330143536.GG28503@telsasoft.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/afb529e6772b4e2b065644a2204697eeaf6c9a96

Modified Files
--------------
src/bin/pg_basebackup/bbstreamer_lz4.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)


pgsql-committers by date:

Previous
From: David Rowley
Date:
Subject: pgsql: Use Generation memory contexts to store tuples in sorts
Next
From: Andrew Dunstan
Date:
Subject: pgsql: Avoid freeing objects during json aggregate finalization