pg_basebackup creates a corrupt file for pg_stat_tmp and pg_replslot on a backup location - Mailing list pgsql-hackers

From Ashutosh Sharma
Subject pg_basebackup creates a corrupt file for pg_stat_tmp and pg_replslot on a backup location
Date
Msg-id CAE9k0Pm7=x_o0W7E2b2s2cWcZdcBGczGdrxttzXOZGp8bEBcGw@mail.gmail.com
Whole thread Raw
Responses Re: pg_basebackup creates a corrupt file for pg_stat_tmp and pg_replslot on a backup location  (Andres Freund <andres@anarazel.de>)
List 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

Attachment

pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: Support for N synchronous standby servers - take 2
Next
From: Kyotaro HORIGUCHI
Date:
Subject: Wrong definition of pgwin32_bind.