Re: Excessive CPU usage in StandbyReleaseLocks()

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Simon Riggs <simon(at)2ndquadrant(dot)com>
Subject: Re: Excessive CPU usage in StandbyReleaseLocks()
Date: 2018-06-26 07:14:23
Message-ID: CAEepm=2=ZXp9u7+a6ygiB1jqf9OewxbDzZthNct5BP0ghj94Uw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jun 21, 2018 at 10:29 AM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> On 2018-06-21 00:25:03 +1200, David Rowley wrote:
>> On 19 June 2018 at 17:43, Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com> wrote:
>> > The problem is that StandbyReleaseLocks() does a linear search of all
>> > known AccessExclusiveLocks when a transaction ends. Luckily, since
>> > v10 (commit 9b013dc2) that is skipped for transactions that haven't
>> > taken any AELs and aren't using 2PC, but that doesn't help all users.
>>
>> Good to see this getting fixed. My original patch [1] to fix this was
>> more along the lines of yours
>
> From that discussion I don't really understand why that wasn't pursued
> further.

I have now pushed this, and back-patched it all the way. There are
three variants:

* master: as previously posted
* 9.5-10: StandbyReleaseOldLocks() works slightly differently
* 9.3-9.4: minor dynahash API change

The difference in StandbyReleaseOldLocks() is due to recent commit
15378c1a, which I gather was due to be back-patched to REL_10_STABLE
at some stage (so I guess the thing to do will be to copy master's new
StandbyReleaseOldLocks() to 10). CC: Simon.

I torture tested this for a while on each branch, but of course any
post-commit review or testing would be very welcome.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2018-06-26 07:16:48 Re: [HACKERS] Moving relation extension locks out of heavyweight lock manager
Previous Message Michael Paquier 2018-06-26 07:13:05 Non-reserved replication slots and slot advancing