pg_basebackup creates a corrupt file for pg_stat_tmp and pg_replslot on a backup location

From: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: pg_basebackup creates a corrupt file for pg_stat_tmp and pg_replslot on a backup location
Date: 2016-04-14 08:13:34
Message-ID: CAE9k0Pm7=x_o0W7E2b2s2cWcZdcBGczGdrxttzXOZGp8bEBcGw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi All,

I tried performing pg_basebackup after creating a symbolic link for
pg_replslot, pg_stat_tmp, pg_log and pg_clog in the source directory and
found that on the backup location pg_stat_tmp, pg_repl_slot is a corrupt
file rather than a link or directory whereas pg_clog and pg_log are getting
skipped. As per the documentation of pg_basebackup, symbolic links on any
directories
other than tablespace and xlog should be skipped. But this statement is not
true for pg_replslot and pg_stat_tmp. The reason is as follows:

pg_basebackup is expecting pg_stat_tmp/pg_replslot to be a directory and
irrespective of whether pg_stat_tmp is empty or not, it will always
include it as a empty directory in backup path. Now, in my case i have
created a softlink for pg_stat_tmp/pg_replslot and pg_basebackup is trying
to create a tar format header without changing the filemode as it does in
case of pg_xlog. Also, linkpath is not considered as in case of pg_tblspc.
This is the reason why a regular file is getting created in the backup path
even though i have a symbolic link in the source path but ideally it should
be skipped.

*Solution:* Skip pg_stat_tmp and pg_replslot if they are symbolic link.
Attached is the patch that fix this issue.

With Regards,
Ashutosh Sharma
EnterpriseDB: *http://www.enterprisedb.com <http://www.enterprisedb.com>*

Attachment Content-Type Size
Allow_pg_basebackup_to_skip_symlinks_if_not_tblspc_and_xlog.patch text/x-patch 1.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2016-04-14 08:15:35 Wrong definition of pgwin32_bind.
Previous Message Masahiko Sawada 2016-04-14 07:40:56 Re: Support for N synchronous standby servers - take 2