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 1lbPwJ-0001cF-46 for pgsql-hackers@arkaria.postgresql.org; Tue, 27 Apr 2021 15:47:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lbPwI-0006DO-2z for pgsql-hackers@arkaria.postgresql.org; Tue, 27 Apr 2021 15:47:54 +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 1lbPwH-0006Af-99 for pgsql-hackers@lists.postgresql.org; Tue, 27 Apr 2021 15:47:53 +0000 Received: from [66.111.4.25] (helo=out1-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lbPwD-0002UG-Gx for pgsql-hackers@lists.postgresql.org; Tue, 27 Apr 2021 15:47:52 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id AC65C5C010D; Tue, 27 Apr 2021 11:47:37 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 27 Apr 2021 11:47:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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= fm2; bh=MRGilOvu/Gkj9KoeRnDvxILSWfHm5x48Nrrpvh1ksXY=; b=eKY/nWwO B8MXN/jQvXVsjUwJDy3MuJvYaeQdNI+5fDS0sAelnTwRJnqQoNQEUHM2CvMgATa1 q0Y5FkmYzfwpd9okSV6qql5/3vaz2B1+Y8beaiRcObbcCo49LA7yx4cLz8RmlPGT HhO1f37cK7f7FkOoyQFnLd8g7unHGrZklTc2qnWgNkCf63zzVB4/XXWC5NAJKwWM N2Hq/ErvYMGhySXOZLnk2ZX/RkxaUQLUCXGlHqY1x9dPR4otclyj3W8f2H9wIX17 08i73MF6BLXG2XdTIDyMDaSuv4e0sSSXbWUq23GjWjQZ5Ne9XhS74VFOq8i9SqQN RgBZnECGnrgOSg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvddvtddgleehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggugfgjfgesthekredttderudenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepueffhfejieeuueffgedvudekgeeltdeviedvieeufeei ieevgfetheeufeethedvnecukfhppeduledtrdelhedrudelrdelheenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghl vhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.95]) by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 27 Apr 2021 11:47:36 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id D989E2A0BB4; Tue, 27 Apr 2021 11:47:33 -0400 (-04) Date: Tue, 27 Apr 2021 11:47:33 -0400 From: Alvaro Herrera To: Amit Langote Cc: Justin Pryzby , Tom Lane , PostgreSQL Hackers Subject: Re: ALTER TABLE .. DETACH PARTITION CONCURRENTLY Message-ID: <20210427154733.GA28178@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.25 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Apr-27, Amit Langote wrote: > On Tue, Apr 27, 2021 at 4:34 PM Amit Langote wrote: > I think we may need a separate context for partdesc_nodetached, likely > with the same kludges as rd_pdcxt. Maybe the first problem will go > away with that as well. Ooh, seems I completely misunderstood what RelationClose was doing. I thought it was deleting the whole rd_pdcxt, *including* the "current" partdesc. But that's not at all what it does: it only deletes the *children* memcontexts, so the partdesc that is currently valid remains valid. I agree that your proposed fix appears to be promising, in that a separate "context tree" rd_pddcxt (?) can be used for this. I'll try it out now. > Few other minor things I noticed: > > + * Store it into relcache. For snapshots built excluding detached > + * partitions, which we save separately, we also record the > + * pg_inherits.xmin of the detached partition that was omitted; this > + * informs a future potential user of such a cached snapshot. > > The "snapshot" in the 1st and the last sentence should be "partdesc"? Doh, yeah. > + * We keep two partdescs in relcache: rd_partdesc_nodetached excludes > + * partitions marked concurrently being detached, while rd_partdesc includes > + * them. > > IMHO, describing rd_partdesc first in the sentence would be better. > Like: rd_partdesc includes all partitions including any that are being > concurrently detached, while rd_partdesc_nodetached excludes them. Makes sense. -- Álvaro Herrera Valdivia, Chile