From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Andrew Dunstan <andrew@dunslane.net>
To: pgsql-committers@postgresql.org
Subject: Re: pgsql: Map basebackup tablespaces using a tablespace_map file
Date: Tue, 12 May 2015 17:33:23 +0300
Message-ID: <55520F33.401@iki.fi> (raw)
In-Reply-To: <E1YsASW-0000Aa-Ut@gemulon.postgresql.org>
References: <E1YsASW-0000Aa-Ut@gemulon.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>
On 05/12/2015 04:42 PM, Andrew Dunstan wrote:
> +
> + /*
> + * Remove the existing symlink if any and Create the symlink
> + * under PGDATA. We need to use rmtree instead of rmdir as
> + * the link location might contain directories or files
> + * corresponding to the actual path. Some tar utilities do
> + * things that way while extracting symlinks.
> + */
> + if (lstat(linkloc, &st) == 0 && S_ISDIR(st.st_mode))
> + {
> + if (!rmtree(linkloc,true))
> + ereport(ERROR,
> + (errcode_for_file_access(),
> + errmsg("could not remove directory \"%s\": %m",
> + linkloc)));
> + }
> + else
> + {
> + if (unlink(linkloc) < 0 && errno != ENOENT)
> + ereport(ERROR,
> + (errcode_for_file_access(),
> + errmsg("could not remove symbolic link \"%s\": %m",
> + linkloc)));
> + }
> +
That's scary. What tar utilitiy replaces the symlink with a non-empty
directory?
What if you call pg_start_backup() and take the backup with a utility
that follows symlinks? I wouldn't recommend using such a tool, but with
this patch, it will zap all the tablespaces. Before this, you at least
got a working database and could read out all the data or fix the
symlinks afterwards.
Why is the RelationCacheInitFileRemove() call moved?
> XLogRecPtr
> do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
> - char **labelfile)
> + char **labelfile, DIR *tblspcdir, List **tablespaces,
> + char **tblspcmapfile, bool infotbssize,
> + bool needtblspcmapfile)
Why does this need to take tblspcdir as argument? Wouldn't it make more
sense to open the directory inside do_pg_start_backup?
In the BASE_BACKUP command, is there any reason to not always include
the tablespace map? IOW, do we really need the TABLESPACE_MAP option?
- Heikki
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: hlinnaka@iki.fi, andrew@dunslane.net
Subject: Re: pgsql: Map basebackup tablespaces using a tablespace_map file
In-Reply-To: <55520F33.401@iki.fi>
References: <E1YsASW-0000Aa-Ut@gemulon.postgresql.org> <55520F33.401@iki.fi>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox