Skip to content

Commit 5b823b1

Browse files
committed
AccessExclusiveLock new relations just after assigning the OID.
This has no user-visible, important consequences, since other sessions' catalog scans can't find the relation until we commit. However, this unblocks introducing a rule about locks required to heap_update() a pg_class row. CREATE TABLE has been acquiring this lock eventually, but it can heap_update() pg_class.relchecks earlier. create_toast_table() has been acquiring only ShareLock. Back-patch to v12 (all supported versions), the plan for the commit relying on the new rule. Reviewed (in an earlier version) by Robert Haas. Discussion: https://postgr.es/m/20240611024525.9f.nmisch@google.com
1 parent 0cecc90 commit 5b823b1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/backend/catalog/heap.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,13 @@ heap_create_with_catalog(const char *relname,
12491249
relpersistence);
12501250
}
12511251

1252+
/*
1253+
* Other sessions' catalog scans can't find this until we commit. Hence,
1254+
* it doesn't hurt to hold AccessExclusiveLock. Do it here so callers
1255+
* can't accidentally vary in their lock mode or acquisition timing.
1256+
*/
1257+
LockRelationOid(relid, AccessExclusiveLock);
1258+
12521259
/*
12531260
* Determine the relation's initial permissions.
12541261
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy