On Tue, Aug 3, 2021 at 5:25 AM Alan Jackson <
lan...@gmail.com> wrote:
>
> We've tracked this time spent down to the use of the rsync '--filter merge /tmp/barman-okldjbe8/pgdata_exclude_and_protect.filter' argument. When this option is excluded (via commenting out the option in the copy controller source), the full restore takes only 5 minutes, and appears perfectly valid.
>
> Thhe pgdata_exclude_and_protect.filter file which is generated by barman consists of over 900,000 lines - which must be evaluated on each of the files being rsynced (which is also several hundred thousand files). Rsync spends an inordinate amount of time parsing and evaluating these filters and exclusion lists before even copying the first byte of data to the target.
Hi Alan.
Thanks for the report and your analysis. I agree that taking 70
minutes to restore 17GB into an empty PGDATA is unfortunate, but i'll
have to spend some time looking at the code before I can formulate an
approach to deal with this.
The code is indeed used for both backups and restores, essentially to
prevent copying files within tablespace directories along with the
main PGDATA (because they are copied separately).
> Perhaps we have a larger number of files in the database than usual, but I'd be surprised if this slowness hadn't been observed before.
I think the reason you might be especially badly affected is that most
people don't have tablespaces whose location is within PGDATA—this is
a configuration that is strongly discouraged by Postgres, which will
even issue a warning if you try to create such a tablespace
("tablespace location should not be inside the data directory"). So if
I'm reading the code correctly, most people won't have much of a
filter at all, where you have ~900k lines.
-- Abhijit