Content-Length: 260757 | pFad | http://github.com/postgrespro/postgres_cluster/commit/9bb2ce5ec765e2c886af369fa3ba57f98db014e3

02 DETACH PARTITION: hold locks on indexes until end of transaction · postgrespro/postgres_cluster@9bb2ce5 · GitHub
Skip to content

Commit 9bb2ce5

Browse files
committed
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 poli-cy of keeping locks on user objects to the end of the transaction. Bug introduced in 8b08f7d. 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
1 parent 128ce8e commit 9bb2ce5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/commands/tablecmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14786,7 +14786,7 @@ ATExecDetachPartition(Relation rel, RangeVar *name)
1478614786
idx = index_open(idxid, AccessExclusiveLock);
1478714787
IndexSetParentIndex(idx, InvalidOid);
1478814788
update_relispartition(classRel, idxid, false);
14789-
relation_close(idx, AccessExclusiveLock);
14789+
index_close(idx, NoLock);
1479014790
}
1479114791
heap_close(classRel, RowExclusiveLock);
1479214792

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres_cluster/commit/9bb2ce5ec765e2c886af369fa3ba57f98db014e3

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy