mirror of
https://github.com/postgres/postgres.git
synced 2025-10-19 15:49:24 +03:00
Use LW_SHARED in walsummarizer.c for WALSummarizerLock lock where possible.
Previously, we used LW_EXCLUSIVE in several places despite only reading WalSummarizerCtl fields. This patch reduces the lock level to LW_SHARED where we are only reading the shared fields. Backpatch to 17, where wal summarization was introduced. Reviewed-by: Nathan Bossart <nathandbossart@gmail.com> Discussion: https://postgr.es/m/CAD21AoDdKhf_9oriEYxY-JCdF+Oe_muhca3pcdkMEdBMzyHyKw@mail.gmail.com Backpatch-through: 17
This commit is contained in:
@@ -644,7 +644,7 @@ WakeupWalSummarizer(void)
|
|||||||
if (WalSummarizerCtl == NULL)
|
if (WalSummarizerCtl == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LWLockAcquire(WALSummarizerLock, LW_EXCLUSIVE);
|
LWLockAcquire(WALSummarizerLock, LW_SHARED);
|
||||||
pgprocno = WalSummarizerCtl->summarizer_pgprocno;
|
pgprocno = WalSummarizerCtl->summarizer_pgprocno;
|
||||||
LWLockRelease(WALSummarizerLock);
|
LWLockRelease(WALSummarizerLock);
|
||||||
|
|
||||||
@@ -685,7 +685,7 @@ WaitForWalSummarization(XLogRecPtr lsn)
|
|||||||
/*
|
/*
|
||||||
* If the LSN summarized on disk has reached the target value, stop.
|
* If the LSN summarized on disk has reached the target value, stop.
|
||||||
*/
|
*/
|
||||||
LWLockAcquire(WALSummarizerLock, LW_EXCLUSIVE);
|
LWLockAcquire(WALSummarizerLock, LW_SHARED);
|
||||||
summarized_lsn = WalSummarizerCtl->summarized_lsn;
|
summarized_lsn = WalSummarizerCtl->summarized_lsn;
|
||||||
pending_lsn = WalSummarizerCtl->pending_lsn;
|
pending_lsn = WalSummarizerCtl->pending_lsn;
|
||||||
LWLockRelease(WALSummarizerLock);
|
LWLockRelease(WALSummarizerLock);
|
||||||
|
Reference in New Issue
Block a user