Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kVCho-0003Gv-0M for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Oct 2020 11:55:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kVChm-0000fr-Vb for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Oct 2020 11:54:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kVChC-0006Qi-Ng for pgsql-hackers@lists.postgresql.org; Wed, 21 Oct 2020 11:54:22 +0000 Received: from mail-io1-xd2e.google.com ([2607:f8b0:4864:20::d2e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kVChA-0007b3-BL for pgsql-hackers@postgresql.org; Wed, 21 Oct 2020 11:54:21 +0000 Received: by mail-io1-xd2e.google.com with SMTP id n6so2782521ioc.12 for ; Wed, 21 Oct 2020 04:54:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=fgn2yBRH8OohOy1hCLGdP/aWfk7YAExF6ToIe2BiiWM=; b=RGOkUaYXif3Vm7Pi7gGXy5w/v3kTM7tO/YzyAD3FhWjW4k76Yd3squaInCmS8m653C qeGApKIzjpf1Smi7ydgwgpbu/Q7Op8YyFIwQqNgvhn75uubuGfl/hqvDNrOvTnpwmXA6 J490hlJYH4C7FXAVepGVuTKVqHg+8sMDf3QrEcBM5npud1rGuPlz854nS6OUlrBvppZv jnVkHQZcw/EXgb8A4r7C7dlA4nHedvlh3RWPQ1Bk+LFtamm93tFYIP2LwMQSNdmoWVa9 omjDulWtKxkWJ5DAP3Z2ucwCjNmlxljf493sSUcsTdBHQ5uVBQXBYx1k1rui7YXoBGbS ynsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=fgn2yBRH8OohOy1hCLGdP/aWfk7YAExF6ToIe2BiiWM=; b=Ct7SDoP40knl7XeJx2ROvDB5CJPtDToJ/zoiWcVVSwtu+/7s/7Bunix2OooWAoHuO/ lASzgVLxYwdt4rNFmRYJ/K3yaA9MC71km0Xlj/0sBtKXy/mRIWZ9Vm12w6SOvUykuh7a 55O9fssJ1P6dPgqVkWPet+PbM7Mpx51J7CcRitAh6VLhHXA8rhklFZpyNKVCIPIxlnpU RSsQ9zmtXcbWQBCffTMnLOEA+2PDAqZ4sKQrjQrv7NZn2zUHrA1IPGuiTkSZH7TYph2c sPGIgYk5gEgNM0del+pnpFaGdNZXr09wQoe+NJrSm1kJQlApgHwKx3NKdpIy7WzKahfW D1Kw== X-Gm-Message-State: AOAM531jUEdW/7VXdSl0fXYSqypD07vuXW0noGkS/tBdtbv2U+c6XQqc dVlAnpifKExyHDy0DKgkptaW3g== X-Google-Smtp-Source: ABdhPJzJsb1kd5ZcwdNx+Z2MAYu3v7fR8Q1DW30by1aa5X7GjpntgR7ruObFdjOQsC5BohYBNtoeqw== X-Received: by 2002:a02:a798:: with SMTP id e24mr2538302jaj.105.1603281259330; Wed, 21 Oct 2020 04:54:19 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id l6sm1158014ilq.61.2020.10.21.04.54.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Oct 2020 04:54:18 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 32EBC800773; Wed, 21 Oct 2020 06:54:17 -0500 (CDT) Date: Wed, 21 Oct 2020 06:54:17 -0500 From: Justin Pryzby To: Tom Lane Cc: Bruce Momjian , pgsql-hackers@postgresql.org Subject: Re: pg_upgrade: fail early if a tablespace dir already exists for new cluster version Message-ID: <20201021115416.GK9241@telsasoft.com> References: <20200925005531.GJ23631@telsasoft.com> <20201009185325.GA24870@momjian.us> <20201009192310.GS17626@telsasoft.com> <20201009234251.GA8419@momjian.us> <20201015233530.GG3797@momjian.us> <20201020230638.GI9241@telsasoft.com> <694458.1603243042@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <694458.1603243042@sss.pgh.pa.us> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Oct 20, 2020 at 09:17:22PM -0400, Tom Lane wrote: > Justin Pryzby writes: > > I wonder if pg_upgrade should try to rmdir() the tablespace dirs before > > restoring global objects, allowing it to succeed, rather than just "failing > > early". > > I'm a little confused about that. If the directories aren't empty, > that will fail, You mean rmdir() will fail, returning -1, which my patch will ignore, and the pg_upgrade will fail, same as it would have before. The goal of the patch is to improve the "empty" case, only. > but if they are, shouldn't the upgrade just work? It fails in "Restoring global objects", which runs "CREATE TABLESPACE". | errmsg("directory \"%s\" already in use as a tablespace", I considered the possibility of changing that, but it seems like this is specific to pg_upgrade. I wouldn't want to change the core server just for that, and it has a good reason for failing in that case: | * The creation of the version directory prevents more than one tablespace | * in a single location. -- Justin