Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z0FBb-00038J-Oa for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Jun 2015 20:22:51 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Z0FBa-0002dg-Fi for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Jun 2015 20:22:50 +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 1Z0FBZ-0002dP-EU for pgsql-hackers@postgresql.org; Wed, 03 Jun 2015 20:22:49 +0000 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Z0FBV-00050L-Re for pgsql-hackers@postgresql.org; Wed, 03 Jun 2015 20:22:47 +0000 Received: from mfilter9-d.gandi.net (mfilter9-d.gandi.net [217.70.178.138]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id 0B87917207C; Wed, 3 Jun 2015 22:22:42 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter9-d.gandi.net Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by mfilter9-d.gandi.net (mfilter9-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id OrpREIQvTVCX; Wed, 3 Jun 2015 22:22:40 +0200 (CEST) X-Originating-IP: 98.122.164.227 Received: from [192.168.10.146] (unknown [98.122.164.227]) (Authenticated sender: adsend@dunslane.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 71BBE172080; Wed, 3 Jun 2015 22:22:39 +0200 (CEST) Message-ID: <556F620E.2010403@dunslane.net> Date: Wed, 03 Jun 2015 16:22:38 -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: Robert Haas , hlinnaka , PostgreSQL-development Subject: Re: Re: [COMMITTERS] pgsql: Map basebackup tablespaces using a tablespace_map file References: <55520F33.401@iki.fi> <55521D27.3010705@dunslane.net> <5553B6B5.6040804@dunslane.net> <5554D470.1080107@dunslane.net> <556DE03B.1020809@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 On 06/02/2015 11:55 PM, Amit Kapila wrote: > On Tue, Jun 2, 2015 at 10:26 PM, Andrew Dunstan > wrote: > > > On 05/15/2015 02:21 AM, Amit Kapila wrote: > > > Find the patch which gets rid of rmtree usage. I have made it as > a separate function because the same code is used from > create_tablespace_directories() as well. I thought of > extending the > same API for using it from destroy_tablespace_directories() as > well, > but due to special handling (especially for ENOENT) in that > function, > I left it as of now. > > > > > > > Well, it seems to me the new function is being altogether way too > trusting about the nature of what it's being asked to remove. In > the first place, the S_ISDIR/rmdir branch should only be for > Windows, and secondly in the other branch we should be checking > that S_ISLNK is true. It would actually be nice if we could test > for a junction point on Windows, but that seems to be a bit > difficult. > > > I think during recovery for tablespace related operations, it is > quite possible to have a directory instead of symlink in some > special cases (see function TablespaceCreateDbspace() and comments > in destroy_tablespace_directories() { ..Try to remove the symlink..}). > Also this new function is being called from > create_tablespace_directories() > which uses the code as written in new function, so it doesn't make much > sense to change it Windows and non-Windows specific code. Looking at it again, this might be not as bad as I thought, but I do think we should probably call the function something other than rmsymlink(). That seems too generic, since it also tries to remove directories - albeit that this will fail if the directory isn't empty. And I still think we should add a test for S_ISLNK in the second branch. As it stands the function could try to unlink anything that's not a directory. That might be safe-ish in the context it's used in for the tablespace code, but it's far from safe enough for a function that's in src/common Given that the function raises an error on failure, I think it will otherwise be OK as is. 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