Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1fe1f42

Browse files
committed
Acquire ProcArrayLock exclusively in ProcArrayClearTransaction.
This corrects an oversight by me in2072932, which madeProcArrayClearTransaction() increment xactCompletionCount. That requires anexclusive lock, obviously.There's other approaches that avoid the exclusive acquisition, but given that a2PC commit is fairly heavyweight, it doesn't seem worth doing so. I've not beenable to measure a performance difference, unsurprisingly. I did add acomment documenting that we could do so, should it ever become a bottleneck.Reported-By: Tom Lane <tgl@sss.pgh.pa.us>Author: Andres Freund <andres@anarazel.de>Discussion:https://postgr.es/m/1355915.1597794204@sss.pgh.pa.us
1 parent2072932 commit1fe1f42

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

‎src/backend/storage/ipc/procarray.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -840,13 +840,20 @@ ProcArrayClearTransaction(PGPROC *proc)
840840
size_tpgxactoff;
841841

842842
/*
843-
* We can skip locking ProcArrayLock exclusively here, because this action
844-
* does not actually change anyone's view of the set of running XIDs: our
845-
* entry is duplicate with the gxact that has already been inserted into
846-
* the ProcArray. But need it in shared mode for pgproc->pgxactoff to stay
847-
* the same.
843+
* Currently we need to lock ProcArrayLock exclusively here, as we
844+
* increment xactCompletionCount below. We also need it at least in shared
845+
* mode for pgproc->pgxactoff to stay the same below.
846+
*
847+
* We could however, as this action does not actually change anyone's view
848+
* of the set of running XIDs (our entry is duplicate with the gxact that
849+
* has already been inserted into the ProcArray), lower the lock level to
850+
* shared if we were to make xactCompletionCount an atomic variable. But
851+
* that doesn't seem worth it currently, as a 2PC commit is heavyweight
852+
* enough for this not to be the bottleneck. If it ever becomes a
853+
* bottleneck it may also be worth considering to combine this with the
854+
* subsequent ProcArrayRemove()
848855
*/
849-
LWLockAcquire(ProcArrayLock,LW_SHARED);
856+
LWLockAcquire(ProcArrayLock,LW_EXCLUSIVE);
850857

851858
pgxactoff=proc->pgxactoff;
852859

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp