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 1kV2kr-00050H-5X for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Oct 2020 01:17:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kV2kp-0007jI-Io for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Oct 2020 01:17:27 +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 1kV2kp-0007j9-Bq for pgsql-hackers@lists.postgresql.org; Wed, 21 Oct 2020 01:17:27 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kV2kn-00070I-CG for pgsql-hackers@postgresql.org; Wed, 21 Oct 2020 01:17:26 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 09L1HMRw694459; Tue, 20 Oct 2020 21:17:22 -0400 From: Tom Lane To: Justin Pryzby cc: Bruce Momjian , pgsql-hackers@postgresql.org Subject: Re: pg_upgrade: fail early if a tablespace dir already exists for new cluster version In-reply-to: <20201020230638.GI9241@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> Comments: In-reply-to Justin Pryzby message dated "Tue, 20 Oct 2020 18:06:38 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <694457.1603243042.1@sss.pgh.pa.us> Date: Tue, 20 Oct 2020 21:17:22 -0400 Message-ID: <694458.1603243042@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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, but if they are, shouldn't the upgrade just work? initdb is not normally unhappy about the target directory existing if it's empty. The reason why rmdir-and-recreate is not a great substitute for "it just works" is that (a) you may lose the intended ownership or permissions of those dirs, (b) you may lack write permission on their parent dirs. So cases where the DBA has pre-created the directories are important to support. regards, tom lane