summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2018-12-20 10:58:22 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2018-12-20 11:11:13 -0300
commit9bb2ce5ec765e2c886af369fa3ba57f98db014e3 (patch)
tree8a409dc7370d0b9debdd8d01611a377870326649
parent128ce8e1a18ed7a83dd0f8dbe7bfb00eb73f200b (diff)
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
-rw-r--r--src/backend/commands/tablecmds.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 7dcfa551bc4..6543eedc3a3 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -14786,7 +14786,7 @@ ATExecDetachPartition(Relation rel, RangeVar *name)
idx = index_open(idxid, AccessExclusiveLock);
IndexSetParentIndex(idx, InvalidOid);
update_relispartition(classRel, idxid, false);
- relation_close(idx, AccessExclusiveLock);
+ index_close(idx, NoLock);
}
heap_close(classRel, RowExclusiveLock);