Re: [HACKERS] Moving relation extension locks out of heavyweight lock manager
Amit Kapila <amit.kapila16@gmail.com>
From: Amit Kapila <amit.kapila16@gmail.com>
To: Masahiko Sawada <masahiko.sawada@2ndquadrant.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Masahiko Sawada <sawada.mshk@gmail.com>, Robert Haas <robertmhaas@gmail.com>, Andres Freund <andres@anarazel.de>, Michael Paquier <michael@paquier.xyz>,
Mithun Cy <mithun.cy@enterprisedb.com>, Thomas Munro <thomas.munro@enterprisedb.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2020-02-12T09:16:48Z
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
On Wed, Feb 12, 2020 at 7:36 AM Masahiko Sawada <masahiko.sawada@2ndquadrant.com> wrote: > > On Wed, 12 Feb 2020 at 00:43, Tom Lane <tgl@sss.pgh.pa.us> wrote: > > > > I took a brief look through this patch. I agree with the fundamental > > idea that we shouldn't need to use the heavyweight lock manager for > > relation extension, since deadlock is not a concern and no backend > > should ever need to hold more than one such lock at once. But it feels > > to me like this particular solution is rather seriously overengineered. > > I would like to suggest that we do something similar to Robert Haas' > > excellent hack (daa7527af) for the !HAVE_SPINLOCK case in lmgr/spin.c, > > that is, > > > > * Create some predetermined number N of LWLocks for relation extension. > > My original proposal used LWLocks and hash tables for relation > extension but there was a discussion that using LWLocks is not good > because it's not interruptible[1]. Because of this reason and that we > don't need to have two lock level (shared, exclusive) for relation > extension lock we ended up with implementing dedicated lock manager > for extension lock. I think we will have that problem if we use LWLocks. > Hmm, but we use LWLocks for (a) WALWrite/Flush (see the usage of WALWriteLock), (b) writing the shared buffer contents (see io_in_progress lock and its usage in FlushBuffer) and might be for few other similar stuff. Many times those take more time than extending a block in relation especially when we combine the WAL write for multiple commits. So, if this is a problem for relation extension lock, then the same thing holds true there also. Now, there are cases like when we extend the relation with multiple blocks, finding victim buffer under this lock, etc. where this can be also equally or more costly, but I think we can improve some of those cases (some of this is even pointed by Andres in his email) if we agree on a fundamental idea of using LWLocks as proposed by Tom. I am not telling that we implement Tom's idea without weighing its pros and cons, but it has an appeal due to its simplicity. -- With Regards, Amit Kapila. EnterpriseDB: http://www.enterprisedb.com