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 1k5D1F-00039L-9Y for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Aug 2020 18:59:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k5D1E-0007DN-4i for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Aug 2020 18:59:36 +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 1k5D1D-0007DG-Ur for pgsql-bugs@lists.postgresql.org; Mon, 10 Aug 2020 18:59:35 +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 1k5D17-0005Sw-GX for pgsql-bugs@lists.postgresql.org; Mon, 10 Aug 2020 18:59:34 +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 07AIxQhX3247406; Mon, 10 Aug 2020 14:59:26 -0400 From: Tom Lane To: Alvaro Herrera cc: Michael Paquier , exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16577: Segfault on altering a table located in a dropped tablespace In-reply-to: <20200810182412.GA19588@alvherre.pgsql> References: <20200810182412.GA19588@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Mon, 10 Aug 2020 14:24:12 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3247404.1597085966.1@sss.pgh.pa.us> Date: Mon, 10 Aug 2020 14:59:26 -0400 Message-ID: <3247405.1597085966@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alvaro Herrera writes: > On 2020-Aug-09, Tom Lane wrote: >> Michael Paquier writes: >>> For a normal table we would complain that the tablespace is not empty >>> when attempting to drop the tablespace. But here we have only one >>> partitioned table still holding references to the tablespace. > Ah, so it turns out that the physical files were necessary after all. > Maybe the solution to this problem is indeed to have them. It means > partly reverting this commit: I think actually the hardest part will be figuring out what is the conversion path, e.g. will pg_upgrade have to know about this. One point that strikes me is that that will put us in a place where "does this relation have storage" is not a binary choice. The possible answers will be "yes", "no", or "has an empty stub file". If we try to take shortcuts rather than handling that honestly, we'll be in for more bugs. > As for the crash at hand, it seems it can be solved easily by making > ruleutils avoid trying to dereference a null pointer, as in the attached > patch. Meh. I have a feeling that that's just the tip of the iceberg of things that will go wrong in this scenario. I'm not sure how much band-aid code we want to expend on the case --- after all, tablespace create/drop is a superuser-only activity, so people aren't doing it carelessly (one hopes). regards, tom lane