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 1kk7X0-0000t0-3J for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Dec 2020 15:25:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kk7Wz-0006sf-1z for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Dec 2020 15:25:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kk7Wy-0006sX-RZ for pgsql-hackers@lists.postgresql.org; Tue, 01 Dec 2020 15:25:28 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kk7Ww-0007uy-6m for pgsql-hackers@lists.postgresql.org; Tue, 01 Dec 2020 15:25:28 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 6A8BE12FC; Tue, 1 Dec 2020 10:25:23 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 01 Dec 2020 10:25:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=HO06xrwI/VZLDB4yR XgR4qyWJK5wmhPXSnECwPcdic4=; b=SpGDTcDoQJJnBT+t16ouFy7NvrzNLMxMK 3SKFXIEvwQHl57heJJ8qb+rolsSoRF/XKjeq8Bbp/lqAEO7tldQPWFC9KsEdtl4u VeEk5t+xjsEoSiCI5hgcsNuAJY1Qem1HcdxAi2b7yaiqf99KjCUsPp5pzDvyQO7i RCfvv0m7PbpkhJng8MPm9YMQ24wJPZgbrv1x91DgI6dE2eKD9X1v39dZgnMdKRqy xbe/6Qtm8kNffOe9iLS1TbmKtossV/Qb0dekE2NU6DRpuSmlR0ALzPwJCtI6tsn5 3Qx3GwRNBTVxLv20lyfhBTJfU2pHkiayLBBto+wHg/a06Z8bxXgOw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudeivddgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggujggfsehttdertddtredvnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpeevgfelveegueejgefhgeetgefhgeehieefheehleetteei udeiiefhgffgheffteenucfkphepudeltddrleehrddukedrjeelnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhv hhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.18.79]) by mail.messagingengine.com (Postfix) with ESMTPA id 34B1E3280063; Tue, 1 Dec 2020 10:25:22 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id D18962A0BB8; Tue, 1 Dec 2020 12:25:19 -0300 (-03) Date: Tue, 1 Dec 2020 12:25:19 -0300 From: Alvaro Herrera To: Justin Pryzby Cc: Amit Langote , pgsql-hackers@lists.postgresql.org Subject: Re: ALTER TABLE .. DETACH PARTITION CONCURRENTLY Message-ID: <20201201152519.GA17514@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201201013051.GA24052@telsasoft.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi Justin, Thanks for all the comments. I'll incorporate everything and submit an updated version later. On 2020-Nov-30, Justin Pryzby wrote: > On Tue, Nov 03, 2020 at 08:56:06PM -0300, Alvaro Herrera wrote: > > +++ b/src/bin/psql/describe.c > > - printfPQExpBuffer(&tmpbuf, _("Partition of: %s %s"), parent_name, > > - partdef); > > + printfPQExpBuffer(&tmpbuf, _("Partition of: %s %s%s"), parent_name, > > + partdef, > > + strcmp(detached, "t") == 0 ? " DETACHED" : ""); > > The attname "detached" is a stretch of what's intuitive (it's more like > "detachING" or half-detached). But I think psql should for sure show something > more obvious to users. Esp. seeing as psql output isn't documented. Let's > figure out what to show to users and then maybe rename the column that, too. OK. I agree that "being detached" is the state we want users to see, or maybe "detach pending", or "unfinisheddetach" (ugh). I'm not sure that pg_inherits.inhbeingdetached" is a great column name. Opinions welcome. > > +PG_KEYWORD("finalize", FINALIZE, UNRESERVED_KEYWORD, BARE_LABEL) > > Instead of finalize .. deferred ? Or ?? Well, I'm thinking that this has to be a verb in the imperative mood. The user is commanding the server to "finalize this detach operation". I'm not sure that DEFERRED fits that grammatical role. If there are other ideas, let's discuss them. ALTER TABLE tst DETACH PARTITION tst_1 FINALIZE <-- decent ALTER TABLE tst DETACH PARTITION tst_1 COMPLETE <-- I don't like it ALTER TABLE tst DETACH PARTITION tst_1 DEFERRED <-- grammatically faulty? > ATExecDetachPartition: > Doesn't this need to lock the table before testing for default partition ? Correct, it does. > I ended up with apparently broken constraint when running multiple loops around > a concurrent detach / attach: > > while psql -h /tmp postgres -c "ALTER TABLE p ATTACH PARTITION p1 FOR VALUES FROM (1)TO(2)" -c "ALTER TABLE p DETACH PARTITION p1 CONCURRENTLY"; do :; done& > while psql -h /tmp postgres -c "ALTER TABLE p ATTACH PARTITION p1 FOR VALUES FROM (1)TO(2)" -c "ALTER TABLE p DETACH PARTITION p1 CONCURRENTLY"; do :; done& > > "p1_check" CHECK (true) > "p1_i_check" CHECK (i IS NOT NULL AND i >= 1 AND i < 2) Not good.