Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YsCB6-0000dh-MX for pgsql-committers@arkaria.postgresql.org; Tue, 12 May 2015 15:33:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YsCB5-0006s3-SB for pgsql-committers@arkaria.postgresql.org; Tue, 12 May 2015 15:33:03 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YsCB5-0006rg-3E for pgsql-committers@postgresql.org; Tue, 12 May 2015 15:33:03 +0000 Received: from relay5-d.mail.gandi.net ([2001:4b98:c:538::197]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1YsCB2-0000N5-HK for pgsql-committers@postgresql.org; Tue, 12 May 2015 15:33:01 +0000 Received: from mfilter1-d.gandi.net (mfilter1-d.gandi.net [217.70.178.130]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id 3C4A841C087; Tue, 12 May 2015 17:32:58 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter1-d.gandi.net Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by mfilter1-d.gandi.net (mfilter1-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id gR7n4EW2vSpl; Tue, 12 May 2015 17:32:56 +0200 (CEST) X-Originating-IP: 98.27.58.255 Received: from [192.168.10.146] (cpe-98-27-58-255.nc.res.rr.com [98.27.58.255]) (Authenticated sender: adsend@dunslane.net) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 3792D41C0F3; Tue, 12 May 2015 17:32:56 +0200 (CEST) Message-ID: <55521D27.3010705@dunslane.net> Date: Tue, 12 May 2015 11:32:55 -0400 From: Andrew Dunstan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: hlinnaka@iki.fi, pgsql-committers@postgresql.org, Amit Kapila Subject: Re: pgsql: Map basebackup tablespaces using a tablespace_map file References: <55520F33.401@iki.fi> In-Reply-To: <55520F33.401@iki.fi> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org On 05/12/2015 10:33 AM, Heikki Linnakangas wrote: > 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? I will let Amit comment on this. > >> 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? Good point. It does look cleaner to do that. > > 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? > > > I assume it was done for minimal disturbance, i.e. that's where we need it. Amit, comments? cheers andrew -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers