pgsql: Acquire ProcArrayLock exclusively in ProcArrayClearTransaction.

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Acquire ProcArrayLock exclusively in ProcArrayClearTransaction.
Date: 2020-08-20 01:35:57
Message-ID: E1k8ZUj-00051o-7o@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Acquire ProcArrayLock exclusively in ProcArrayClearTransaction.

This corrects an oversight by me in 20729324078, which made
ProcArrayClearTransaction() increment xactCompletionCount. That requires an
exclusive lock, obviously.

There's other approaches that avoid the exclusive acquisition, but given that a
2PC commit is fairly heavyweight, it doesn't seem worth doing so. I've not been
able to measure a performance difference, unsurprisingly. I did add a
comment documenting that we could do so, should it ever become a bottleneck.

Reported-By: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Author: Andres Freund <andres(at)anarazel(dot)de>
Discussion: https://postgr.es/m/1355915.1597794204@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1fe1f42e3e85279e1cb8b004b3b076a04bde4cee

Modified Files
--------------
src/backend/storage/ipc/procarray.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2020-08-20 01:35:58 Re: pgsql: Fix race condition in snapshot caching when 2PC is used.
Previous Message Alvaro Herrera 2020-08-19 22:37:04 Re: pgsql: snapshot scalability: cache snapshots using a xact completion co