mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Clarify what is protected by WaitLSNLock
Not just WaitLSNState.waitersHeap, but also WaitLSNState.procInfos and updating of WaitLSNState.minWaitedLSN is protected by WaitLSNLock. There is one now documented exclusion on fast-path checking of WaitLSNProcInfo.inHeap flag. Discussion: https://postgr.es/m/202404030658.hhj3vfxeyhft%40alvherre.pgsql
This commit is contained in:
@ -109,13 +109,13 @@ addLSNWaiter(XLogRecPtr lsn)
|
||||
{
|
||||
WaitLSNProcInfo *procInfo = &waitLSN->procInfos[MyProcNumber];
|
||||
|
||||
LWLockAcquire(WaitLSNLock, LW_EXCLUSIVE);
|
||||
|
||||
Assert(!procInfo->inHeap);
|
||||
|
||||
procInfo->procnum = MyProcNumber;
|
||||
procInfo->waitLSN = lsn;
|
||||
|
||||
LWLockAcquire(WaitLSNLock, LW_EXCLUSIVE);
|
||||
|
||||
pairingheap_add(&waitLSN->waitersHeap, &procInfo->phNode);
|
||||
procInfo->inHeap = true;
|
||||
updateMinWaitedLSN();
|
||||
@ -203,6 +203,12 @@ WaitLSNSetLatches(XLogRecPtr currentLSN)
|
||||
void
|
||||
WaitLSNCleanup(void)
|
||||
{
|
||||
/*
|
||||
* We do a fast-path check of the 'inHeap' flag without the lock. This
|
||||
* flag is set to true only by the process itself. So, it's only possible
|
||||
* to get a false positive. But that will be eliminated by a recheck
|
||||
* inside deleteLSNWaiter().
|
||||
*/
|
||||
if (waitLSN->procInfos[MyProcNumber].inHeap)
|
||||
deleteLSNWaiter();
|
||||
}
|
||||
|
Reference in New Issue
Block a user