sendFileWithContent() does not advance the source pointer

From: Antonin Houska <ah(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org
Subject: sendFileWithContent() does not advance the source pointer
Date: 2022-12-08 19:44:05
Message-ID: 15764.1670528645@antos
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

When checking something else in the base backup code, I've noticed that
sendFileWithContent() does not advance the 'content' pointer. The sink buffer
is large enough (32kB) so that the first iteration usually processes the whole
file (only special files are processed by this function), and thus that the
problem is hidden.

However it's possible to hit the issue: if there are too many tablespaces,
pg_basebackup generates corrupted tablespace_map. Instead of writing all the
tablespace paths it writes only some and then starts to write the contents
from the beginning again.

The attached script generates scripts to create many tablespaces as well as
the underlying directories. Fix is attached here as well.

--
Antonin Houska
Web: https://www.cybertec-postgresql.com

Attachment Content-Type Size
many.sh text/x-shellscript 432 bytes
advance_content_pointer.diff text/x-diff 462 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2022-12-08 20:56:43 Re: Aggregate node doesn't include cost for sorting
Previous Message Nathan Bossart 2022-12-08 19:08:08 Re: Documenting MERGE INTO ONLY ...