pgsql: DETACH PARTITION: hold locks on indexes until end oftransaction - Mailing list pgsql-committers

From Alvaro Herrera
Subject pgsql: DETACH PARTITION: hold locks on indexes until end oftransaction
Date
Msg-id E1gZzNj-0007Sh-PO@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
DETACH PARTITION: hold locks on indexes until end of transaction

When a partition is detached from its parent, we acquire locks on all
attached indexes to also detach them ... but we release those locks
immediately.  This is a violation of the policy of keeping locks on user
objects to the end of the transaction.  Bug introduced in 8b08f7d4820f.

It's unclear that there are any ill effects possible, but it's clearly
wrong nonetheless.  It's likely that bad behavior *is* possible, but
mostly because the relation that the index is for is only locked with
AccessShareLock, which is an older bug that shall be fixed separately.

While touching that line of code, close the index opened with
index_open() using index_close() instead of relation_close().
No difference in practice, but let's be consistent.

Unearthed by Robert Haas.

Discussion: https://postgr.es/m/CA+TgmoYruJQ+2qnFLtF1xQtr71pdwgfxy3Ziy-TxV28M6pEmyA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0c2377152f2b68d46a27d5821a2327b6ca441fca

Modified Files
--------------
src/backend/commands/tablecmds.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)


pgsql-committers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: pgsql: Remove function names from error messages
Next
From: Tom Lane
Date:
Subject: pgsql: Make bitmapset.c use 64-bit bitmap words on 64-bit machines.