Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YsdSH-0002kZ-GW for pgsql-hackers@arkaria.postgresql.org; Wed, 13 May 2015 20:40:37 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YsdSG-0003cF-MS for pgsql-hackers@arkaria.postgresql.org; Wed, 13 May 2015 20:40:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YsdSE-0003c0-Dc for pgsql-hackers@postgresql.org; Wed, 13 May 2015 20:40:34 +0000 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1YsdS8-0005by-4l for pgsql-hackers@postgresql.org; Wed, 13 May 2015 20:40:30 +0000 Received: from mfilter33-d.gandi.net (mfilter33-d.gandi.net [217.70.178.164]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id 5669D172067; Wed, 13 May 2015 22:40:25 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter33-d.gandi.net Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by mfilter33-d.gandi.net (mfilter33-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id EQOFEwkZmhqO; Wed, 13 May 2015 22:40:23 +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 relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 45AB117209F; Wed, 13 May 2015 22:40:23 +0200 (CEST) Message-ID: <5553B6B5.6040804@dunslane.net> Date: Wed, 13 May 2015 16:40:21 -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: Amit Kapila CC: hlinnaka , PostgreSQL-development Subject: Re: [COMMITTERS] pgsql: Map basebackup tablespaces using a tablespace_map file References: <55520F33.401@iki.fi> <55521D27.3010705@dunslane.net> In-Reply-To: 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-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org [redirecting to -hackers] On 05/12/2015 01:30 PM, Amit Kapila wrote: > On Tue, May 12, 2015 at 9:02 PM, Andrew Dunstan > wrote: > > > 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? > > > IIRC, it was star utility by using --copysymlinks options. > It will actually copy the symlink data at appropriate location, > but will not maintain symlink after extraction. > I don't have a link handly for it, but can again search for > it and send you if you want to have a look. > > 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. > > > > Yeah, but I don't think user will do such a thing without > being aware of the same and if he is aware, he will either > restore the symlinks before starting the server or would > atleast keep a copy of such a backup until he is able to > restore the database completely. > > Do you think adding a note in docs makes sense? How about if we simply abort if we find a non-symlink where we want the symlink to be, and only remove something that is actually a symlink (or a junction point, which is more or less the same thing)? Then it would be up to the user to recover the situation, by moving or removing the offending file/directory, and trying again. cheers andrew -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers