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 1kQxz8-00034R-BF for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Oct 2020 19:23:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kQxz7-0005f5-4v for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Oct 2020 19:23:21 +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 1kQxz6-0005eY-QI for pgsql-hackers@lists.postgresql.org; Fri, 09 Oct 2020 19:23:20 +0000 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kQxyz-0002Go-IX for pgsql-hackers@postgresql.org; Fri, 09 Oct 2020 19:23:19 +0000 Received: by mail-io1-xd35.google.com with SMTP id r4so3587708ioh.0 for ; Fri, 09 Oct 2020 12:23:13 -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=xk9sCP8qInlCAv6kTsSfjSiNCME2yoEW+BNJ4GTBDkY=; b=MwbLa9VWqW7ATgkTPgcCW4e815DHFHsmXp0Ti3X1nXjsH93cCD/ATjI2nnPSnGPsWC YSZrP73ZlwhCyusy78sCjhhAkmgkksUDC139YvWNJ3r6wGyA53+0bE8nkLX+en7JsSA4 u8yArPNkZcHXV/ZI83oSKtf82wZVx7vteWBHw5RvAP6CnJ9s4RFBlk73AR4eXss2DQlL AvXRS9Tl8v//4mqQQuaq1dQ5Aj44o+InCFHJ43iZRwha65oipv0W8S4bF3DaKDxAn5cy JE78aIugw+5sU57rfA4ld0DfqAwpdvvbDttbfG03pgaL5QuPrIGvfbzIp1vD/OEBiI80 Yylg== 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=xk9sCP8qInlCAv6kTsSfjSiNCME2yoEW+BNJ4GTBDkY=; b=m8BmC1fZBNquYKozeR0W6mBmv7QtCGO8U6RnnhpwmdXrWhhuXpHbRnIPLjqBVYKvB+ /2ou0YienCX2trSbd7AkMaKvcOqenEzKvj9I6m8I1FeRRWJQErECE47qdFulleWpHysl 3MRIwG8R8bOJFfDbEMl5aa9mq5bikBlJrXQrNodnHHqk7MJpYOj8RHeSpDiOiXu3IT/C D7dK+muIh5UZZIUAYjyZHvU+2syHfezSmuSz2/JFK83V6SUQ3gGOt65yzzXbon+JtpW9 +BkIXyp9AxBePhpdMehDsybkKq50PDZ11YPBWzXgn3M1gFGcQWihvPFuzYW/ph8KImdv QXCw== X-Gm-Message-State: AOAM531b4JjFQP5PJM8UGKiqAQy/2cRrlVQNYAv+ajbse1SUkR7QpcGJ q2p46NiBPVrjvjA33Zkw+AAYdg== X-Google-Smtp-Source: ABdhPJxW9TIFWr3oOLNMMAve4vKRAiCTR4viewA8UB8kN/fx8KBV+hWxpfJQEVP2iqE0UaiVhW0KVw== X-Received: by 2002:a6b:7841:: with SMTP id h1mr10290243iop.72.1602271392584; Fri, 09 Oct 2020 12:23:12 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id 69sm3935032iou.42.2020.10.09.12.23.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Oct 2020 12:23:11 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id D56768011C3; Fri, 9 Oct 2020 14:23:10 -0500 (CDT) Date: Fri, 9 Oct 2020 14:23:10 -0500 From: Justin Pryzby To: Bruce Momjian Cc: pgsql-hackers@postgresql.org Subject: Re: pg_upgrade: fail early if a tablespace dir already exists for new cluster version Message-ID: <20201009192310.GS17626@telsasoft.com> References: <20200925005531.GJ23631@telsasoft.com> <20201009185325.GA24870@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201009185325.GA24870@momjian.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 Fri, Oct 09, 2020 at 02:53:25PM -0400, Bruce Momjian wrote: > On Thu, Sep 24, 2020 at 07:55:31PM -0500, Justin Pryzby wrote: > > This should be caught during --check, or earlier in the upgrade, rather than > > only after dumping the schema. > > > > Typically, the tablespace dir would be left behind by a previous failed upgrade > > attempt, causing a cascade of failured upgrades. I guess I may not be the only > > one with a 3 year old wrapper which has a hack to check for this. > > This is an interesting failure case I never considered --- running > pg_upgrade, having it fail, deleting and recreating the _new_ cluster > directory, but not removing the new cluster's tablepace directories. I > was able to recreate the failure, and verify that your patch properly > throws an error during 'check' for this case. > > Modified patch attached. I plan to apply this to all supported Postgres > versions. Thanks for looking. It hits me a bunch of times every year. > + * Check that tablespace directories do not already exist for new cluster. > + * If they do, it would cause an error while restoring global objects. > + * This allows the failure to be detected at check time, rather than > + * during schema restore. > + * > + * Note, v8.4 has no tablespace_suffix, which is fine as long as the new > + * cluster version has a suffix. In my local branch, I had revised this comment to say: + * Note, v8.4 has no tablespace_suffix, which is fine so long as the version we + * being upgraded *to* has a suffix, since it's not allowed to pg_upgrade from + * a version to the same version if tablespaces are in use. Cheers, -- Justin