From 1c142612c846cd01ed0615041e09e6fab7d44571 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Thu, 20 Dec 2018 16:42:13 -0300 Subject: [PATCH] Fix lock level used for partition when detaching it For probably bogus reasons, we acquire only AccessShareLock on the partition when we try to detach it from its parent partitioned table. This can cause ugly things to happen if another transaction is doing any sort of DDL to the partition concurrently. Upgrade that lock to ShareUpdateExclusiveLock, which per discussion seems to be the minimum needed. Reported by Robert Haas. Discussion: https://postgr.es/m/CA+TgmoYruJQ+2qnFLtF1xQtr71pdwgfxy3Ziy-TxV28M6pEmyA@mail.gmail.com --- src/backend/commands/tablecmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 08e9bfcbf18..ec974d11833 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -13865,7 +13865,7 @@ ATExecDetachPartition(Relation rel, RangeVar *name) new_repl[Natts_pg_class]; ObjectAddress address; - partRel = heap_openrv(name, AccessShareLock); + partRel = heap_openrv(name, ShareUpdateExclusiveLock); /* All inheritance related checks are performed within the function */ RemoveInheritance(partRel, rel); -- 2.39.5