Re: [HACKERS] Patch to improve performance of replay of AccessExclusiveLock - Mailing list pgsql-hackers

From Simon Riggs
Subject Re: [HACKERS] Patch to improve performance of replay of AccessExclusiveLock
Date
Msg-id CANP8+jJhWBeV3dSu_KpqR+ZH=8gWZV8e-0K8bMdE1t5=VKyiug@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] Patch to improve performance of replay of AccessExclusiveLock  (David Rowley <david.rowley@2ndquadrant.com>)
Responses Re: [HACKERS] Patch to improve performance of replay of AccessExclusiveLock  (David Rowley <david.rowley@2ndquadrant.com>)
List pgsql-hackers
On 16 March 2017 at 09:52, David Rowley <david.rowley@2ndquadrant.com> wrote:

> I was just trying to verify if it was going to do the correct thing in
> regards to subtransactions and I got a little confused at the comments at
> the top of StandbyAcquireAccessExclusiveLock():
>
>  * We record the lock against the top-level xid, rather than individual
>  * subtransaction xids. This means AccessExclusiveLocks held by aborted
>  * subtransactions are not released as early as possible on standbys.
>
> if this is true, and it seems to be per LogAccessExclusiveLock(), does
> StandbyReleaseLockTree() need to release the locks for sub transactions too?
>
> This code:
>
> for (i = 0; i < nsubxids; i++)
> StandbyReleaseLocks(subxids[i]);

Yes, you are correct, good catch. It's not broken, but the code does
nothing, slowly.

We have two choices... remove this code or assign locks against subxids.

1. In xact_redo_abort() we can just pass NULL to
StandbyReleaseLockTree(), keeping the other code as is for later
fixing by another approach.

2. In LogAccessExclusiveLock() we can use GetCurrentTransactionId()
rather than GetTopTransactionId(), so that we assign the lock to the
subxid rather than the top xid. That could increase lock traffic, but
less likely. It also solves the problem of early release when AELs
held by subxids.

(2) looks safe enough, so patch attached.

-- 
Simon Riggs                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachment

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: [HACKERS] Microvacuum support for Hash Index
Next
From: Simon Riggs
Date:
Subject: Re: [HACKERS] Patch to improve performance of replay of AccessExclusiveLock