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 1kSrlB-0000RM-OP for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Oct 2020 01:08:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kSrlA-0001kP-IT for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Oct 2020 01:08:48 +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 1kSrlA-0001kI-CJ for pgsql-hackers@lists.postgresql.org; Thu, 15 Oct 2020 01:08:48 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kSrl8-0006ZD-2H for pgsql-hackers@lists.postgresql.org; Thu, 15 Oct 2020 01:08:48 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 8BC29CB4; Wed, 14 Oct 2020 21:08:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 14 Oct 2020 21:08:43 -0400 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=3K2/0KrVGYUQSeX2V uu+Mhxx7eEGlzAcYfyRB/Oh1e4=; b=GqZdWEP+KyLghunrF74Q3gFVPMZlpbnwn drsAUAC9DOD2W/u3jOHK0o/DdbQ5mk/xEzCsL3a3jfzqCV2uIocBEcOxt5fqzY8F hSJ8IxNaXO6jo/mYEYUWaDnJxChWUccq/VWM7oK/a7v2miPMDXzn8+f3YyFyRXVm termxMD+LsE67iI2Ptp9OHbsSLx2hegh02/uomMSb2Ejl1oqlqy70XKywNmTc8gx 4fHtJhM0pYKsRA//fdB7x/69nFC+ZB60pzKP9LuDV7bfAMjR7IodOK6IdRTWND9f wJYQA7zfdt0CUJnHN8y4UNZn1qvIbuyhlk2/PJqQ5KpiY/L6dpteQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedriedvgdegvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkgggtuggjfgesthdtredttdervdenucfhrhhomheptehlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqne cuggftrfgrthhtvghrnhepvefgleevgeeujeeghfegteeghfegheeifeehheelteetiedu ieeihffggfehffetnecukfhppeduledtrdelhedrudelrddugeeknecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhv hhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.148]) by mail.messagingengine.com (Postfix) with ESMTPA id 74C88328005D; Wed, 14 Oct 2020 21:08:42 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 4F71B2A14E9; Wed, 14 Oct 2020 22:08:40 -0300 (-03) Date: Wed, 14 Oct 2020 22:08:40 -0300 From: Alvaro Herrera To: Andy Fan Cc: Pg Hackers Subject: Re: ALTER TABLE .. DETACH PARTITION CONCURRENTLY Message-ID: <20201015010840.GA20821@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Oct-15, Andy Fan wrote: > I think if it is possible to implement the detech with a NoWait option . > > ALTER TABLE ... DETACH PARTITION .. [NoWait]. > > if it can't get the lock, raise "Resource is Busy" immediately, > without blocking others. this should be a default behavior. If > people do want to keep trying, it can set a ddl_lock_timeout to > 'some-interval', in this case, it will still block others(so it can't > be as good as what you are doing, but very simple), however the user > would know what would happen exactly and can coordinate with their > application accordingly. I'm sorry about this since it is a bit of > off-topics or it has been discussed already. Hi. I don't think this has been discussed, but it doesn't really solve the use case I want to -- in many cases where the tables are continuously busy, this would lead to starvation. I think the proposal to make the algorithm work with reduced lock level is much more useful. I think you can already do NOWAIT behavior, with LOCK TABLE .. NOWAIT followed by DETACH PARTITION, perhaps with a nonzero statement timeout.