Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wAWc3-0003gP-06 for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 17:22:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wAWbz-000tkD-2J for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 17:22:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wAWbz-000tk5-1N for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2026 17:22:44 +0000 Received: from fhigh-a6-smtp.messagingengine.com ([103.168.172.157]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wAWby-000000001kc-14sB for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2026 17:22:43 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id DC73F14000E7; Wed, 8 Apr 2026 13:22:41 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Wed, 08 Apr 2026 13:22:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1775668961; x=1775755361; bh=ZmLdULwKqSmo5Xw4csv2PmqinAOX1ME8Q8yyl6UENd4=; b= X9S/pr0jCNk864bmmQQ/cf33qRdWEyYu6csvaeOWer7hibDPQrtWJS06fn63+qgB lvZYF2dXgl6vJhvzCNM7VUdw741fz7m4mF1P+t87aALIuCwcQeY1swsMPkz7D7NL AJVDqNXqkD3TShMnLja3eqvErDkJ4lmRUqmwY2zkezhVeoVva+GiuBngKYrQpxIY I8os3qF1+ooymYc8VTfdgzGRdAWM1/X5SxfXTctpaH8NVgkIMfwdeJvuZrYMzcFK osg8v+H5vn6RXo/mfILm9oUvBHKYYWUFhz6zbAduSeBX55m+LVkQC7cX+FWbcMul M2Ib9jAioLvJlsV131X5kw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1775668961; x= 1775755361; bh=ZmLdULwKqSmo5Xw4csv2PmqinAOX1ME8Q8yyl6UENd4=; b=l loA6a7Bilrf1ziAe8xvvRAokPReyF2TLuQbicThzzaPhtfaxo8n17qWZdzcl99M7 Z7Ss0qFTOXOhOe656GKfjBcwhbb6WzsY31C5IrBxUdqRLSyrNRWztNh1erPVo+Pv QuiGLyX/aAhE0uyqYDdZXy5xamiIlQZSPL9RnkBJU6A7ZgLxxW2Xa05e9Fnz8Smz n67ICo/z4JFyRRhS8elBluhazkq6vPj5wQVafREZXM+OxJ+Q8+dHzfDUS7XOSlnr ep5J5eUMFcNFTh2EKtNX9FpRvogrT5J8TpJFZ6NpQ+E3AXwZk8XyQLU7e29JfDPh vln18gnVpFbdvy136SrDQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgddvgeduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvvefukfhfgggtugfgjgestheksfdttddtjeenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnheptdelledvgfejvdffieeukeefueelfffhgeffhffgffekveeuheeihefhiefg hfdvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hnughrvghssegrnhgrrhgriigvlhdruggvpdhnsggprhgtphhtthhopeekpdhmohguvgep shhmthhpohhuthdprhgtphhtthhopegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprd horhhgpdhrtghpthhtoheprghhsegthigsvghrthgvtgdrrghtpdhrtghpthhtoheprghm ihhtrdhkrghpihhlrgduieesghhmrghilhdrtghomhdprhgtphhtthhopegsohgvkhgvfi hurhhmodhpohhsthhgrhgvshesghhmrghilhdrtghomhdprhgtphhtthhopehmihhhrghi lhhnihhkrghlrgihvghusehgmhgrihhlrdgtohhmpdhrtghpthhtohepshhrihhnrghthh dvudeffeesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhs sehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrghdprhgtphhtthhopehrohgsseigii hilhhlrgdrnhgvth X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 8 Apr 2026 13:22:41 -0400 (EDT) Date: Wed, 8 Apr 2026 13:22:41 -0400 From: Andres Freund To: Amit Kapila Cc: Alvaro Herrera , Mihail Nikalayeu , Antonin Houska , Srinath Reddy Sadipiralla , Matthias van de Meent , Pg Hackers , Robert Treat Subject: Re: Adding REPACK [concurrently] Message-ID: References: <202604062213.cgo352cdsgsm@alvherre.pgsql> <4n4q3preb3lgyhpzstebhux7b2aojhsw7gik4ivaznyggiezrs@lrznutssxlh2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2026-04-08 14:05:49 +0530, Amit Kapila wrote: > On Wed, Apr 8, 2026 at 1:54 AM Andres Freund wrote: > > On 2026-04-07 00:22:32 +0200, Alvaro Herrera wrote: > > > From 4303eea0a72408183f9f5afcf8d2801df20f8ffe Mon Sep 17 00:00:00 2001 > > > From: Antonin Houska > > > Date: Wed, 1 Apr 2026 17:35:47 +0200 > > > Subject: [PATCH v56 3/3] Error out any process that would block at REPACK > > > > > > Any process waiting on REPACK to release its lock would actually cause > > > it to deadlock when it tries to upgrade its lock to AEL, losing all work > > > done to that point. We avoid this by teaching the deadlock detector to > > > raise an error when this condition is detected. > > > > I'm rather doubtful that that is ok. > > > > Another possible idea is that after copying table_data to the new > table, we mark the old table as in_use_by_repack and release the > ShareUpdateExclusiveLock on the old table. Then the function > CheckTableNotInUse() should be updated to give an ERROR if the table > is marked as in_use_by_repack. Now, acquiring AEL by repack > (concurrently) should be safe because all concurrent DDLs should be > errored out due to flag in_use_by_repack. Can this address the problem > we are worried about the lock upgrade? I don't think this is a viable path. You need to prevent any further lock acquisitions on the relation to be able to swap it, not just conflicting DDL. And you need to wait for all pre-existing locks to have been released. That doesn't really get easier by what you propose. I don't think CheckTableNotInUse() would work anyway - don't we already hold locks by the point we call it? And even if that were not the case, there are several paths to locking relations that don't ever go anywhere near CheckTableNotInUse(). Greetings, Andres Freund