Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YsBFY-0006MX-1f for pgsql-committers@arkaria.postgresql.org; Tue, 12 May 2015 14:33:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YsBFX-0001bw-9X for pgsql-committers@arkaria.postgresql.org; Tue, 12 May 2015 14:33:35 +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 1YsBFW-0001bq-IJ for pgsql-committers@postgresql.org; Tue, 12 May 2015 14:33:34 +0000 Received: from mail-wi0-x232.google.com ([2a00:1450:400c:c05::232]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1YsBFR-0007cy-2T for pgsql-committers@postgresql.org; Tue, 12 May 2015 14:33:31 +0000 Received: by wicnf17 with SMTP id nf17so18399186wic.1 for ; Tue, 12 May 2015 07:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:reply-to:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=E0Wnu3RJKZhKWucVcaxDH7cMgp8iJh3kh+MNOcWYmKU=; b=nOkXX9mqTnVaMgPUmy65WhJ8jvcR//O0pyu6TAV1LdeCmhhb4Fb8Qhk8M8whuoFycS vjVc/6bcL3YJgk73RqG2VPZXU1kmyalRb4zVYVoBUfwgoggRPkAek6gPT8eaKB56FLWM AyCKwGOo8kuHIfMKykHkI0zMEcfnQE+cHOiA4HWDSY4JzjrlrVhz3DzfY93QmNtHVwa1 Tn+APyBMgCe8DMMXr5NcTuzkiG7POCSvXtkpVSeFGQcJ0+HdbOtCEn4kxqgO1pX6O4ZB bb8ayXQq5r8XjBcGjXHvGnqcjS5jJYhQECBbUm6GHRijxLEVebyBfe55bg1M6UCjhb4D yumQ== X-Received: by 10.194.79.135 with SMTP id j7mr31315133wjx.0.1431441206318; Tue, 12 May 2015 07:33:26 -0700 (PDT) Received: from [192.168.1.99] (dsl-hkibrasgw1-58c38f-82.dhcp.inet.fi. [88.195.143.82]) by mx.google.com with ESMTPSA id be6sm28038496wjb.14.2015.05.12.07.33.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2015 07:33:25 -0700 (PDT) Message-ID: <55520F33.401@iki.fi> Date: Tue, 12 May 2015 17:33:23 +0300 From: Heikki Linnakangas Reply-To: hlinnaka@iki.fi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.6.0 MIME-Version: 1.0 To: Andrew Dunstan , pgsql-committers@postgresql.org Subject: Re: pgsql: Map basebackup tablespaces using a tablespace_map file References: 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-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org 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