Re: [HACKERS] Moving relation extension locks out of heavyweight lock manager
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Thomas Munro <thomas.munro@enterprisedb.com>, Amit Kapila <amit.kapila16@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2017-12-11T20:25:12Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Allow page lock to conflict among parallel group members.
- 3ba59ccc896e 13.0 landed
-
Allow relation extension lock to conflict among parallel group members.
- 85f6b49c2c53 13.0 landed
-
Add assert to ensure that page locks don't participate in deadlock cycle.
- 72e78d831ab5 13.0 landed
-
Assert that we don't acquire a heavyweight lock on another object after
- 15ef6ff4b985 13.0 landed
-
Fix unsafe usage of strerror(errno) within ereport().
- 81256cd05f07 11.0 cited
Hi, On 2017-12-11 15:15:50 -0500, Robert Haas wrote: > +* Relation extension locks. Only one process can extend a relation at > +a time; we use a specialized lock manager for this purpose, which is > +much simpler than the regular lock manager. It is similar to the > +lightweight lock mechanism, but is ever simpler because there is only > +one lock mode and only one lock can be taken at a time. A process holding > +a relation extension lock is interruptible, unlike a process holding an > +LWLock. > +/*------------------------------------------------------------------------- > + * > + * extension_lock.c > + * Relation extension lock manager > + * > + * This specialized lock manager is used only for relation extension > + * locks. Unlike the heavyweight lock manager, it doesn't provide > + * deadlock detection or group locking. Unlike lwlock.c, extension lock > + * waits are interruptible. Unlike both systems, there is only one lock > + * mode. > + * > + * False sharing is possible. We have a fixed-size array of locks, and > + * every database OID/relation OID combination is mapped to a slot in > + * the array. Therefore, if two processes try to extend relations that > + * map to the same array slot, they will contend even though it would > + * be OK to let both proceed at once. Since these locks are typically > + * taken only for very short periods of time, this doesn't seem likely > + * to be a big problem in practice. If it is, we could make the array > + * bigger. For me "very short periods of time" and journaled metadatachanging filesystem operations don't quite mesh. Language lawyering aside, this seems quite likely to bite us down the road. It's imo perfectly fine to say that there's only a limited number of file extension locks, but that there's a far from neglegible chance of conflict even without the array being full doesn't seem nice. Think this needs use some open addressing like conflict handling or something alike. Greetings, Andres Freund