Re: Using base backup exclusion filters to reduce data transferred with pg_rewind

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Fujii Masao <masao.fujii@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Stephen Frost <sfrost@snowman.net>, Anastasia Lubennikova <a.lubennikova@postgrespro.ru>, Michael Paquier <michael.paquier@gmail.com>, Postgres hackers <pgsql-hackers@postgresql.org>
Date: 2018-03-27T22:54:59Z
Lists: pgsql-hackers
On Wed, Mar 28, 2018 at 04:13:25AM +0900, Fujii Masao wrote:
> This code is almost ok in practice, but using the check of
> "strstr(path, localpath) == path" is more robust here?

No problems with that either.

> Using the following code instead is more robust?
> This original code is almost ok in practice, though.
> 
>     filename = last_dir_separator(path);
>     if (filename == NULL)
>         filename = path;
>     else
>         filename++;
>     if (strcmp(filename, excludeFiles[excludeIdx]) == 0)

Indeed, using last_dir_separator is a better idea for files.  I was
looking for something like that actually.

> +      (everything except the relation files). Similarly to base backups,
> +      the contents of the directories <filename>pg_dynshmem/</filename>,
> +      <filename>pg_notify/</filename>, <filename>pg_replslot/</filename>,
> +      <filename>pg_serial/</filename>, <filename>pg_snapshots/</filename>,
> +      <filename>pg_stat_tmp/</filename>, and
> +      <filename>pg_subtrans/</filename> are omitted from the data copied
> +      from the source cluster. Any file or directory beginning with
> +      <filename>pgsql_tmp</filename> is omitted, as well as are
> +      <filename>backup_label</filename>,
> +      <filename>tablespace_map</filename>,
> +      <filename>pg_internal.init</filename>,
> +      <filename>postmaster.opts</filename> and
> +      <filename>postmaster.pid</filename>.
> 
> I don't think this description is necessary. The doc for pg_basebackup
> also doesn't seem to have this kind of description.

Those are listed in backup.sgml.  And I really think that we should at
least document that the same type of exclusion filters as base backups
are used in pg_rewind.  If you don't want to include the whole list,
then let's use a reference to backup-lowlevel-base-backup-data.

> So attached is the patch that I updated based on your patch and
> am thinking to apply.

Thanks.  Except for the documentation part, I am OK for the changes
proposed.
--
Michael

Commits

  1. Make pg_rewind skip files and directories that are removed during server start.