pg_basebackup: Fix code that thinks about LZ4 buffer size.
authorRobert Haas <rhaas@postgresql.org>
Mon, 4 Apr 2022 14:36:23 +0000 (10:36 -0400)
committerRobert Haas <rhaas@postgresql.org>
Mon, 4 Apr 2022 14:36:23 +0000 (10:36 -0400)
commitafb529e6772b4e2b065644a2204697eeaf6c9a96
tree54ccaf4a8631f445724b565e4bfbcf5d455cf333
parent40af10b571bdabbab06839d090083c9f9c2091d2
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
src/bin/pg_basebackup/bbstreamer_lz4.c