mirror of
https://github.com/postgres/postgres.git
synced 2025-12-21 05:21:08 +03:00
Use atomic access for SlruShared->latest_page_number
The new concurrency model proposed for slru.c to improve performance does not include any single lock that would coordinate processes doing concurrent reads/writes on SlruShared->latest_page_number. We can instead use atomic reads and writes for that variable. Author: Dilip Kumar <dilipbalaut@gmail.com> Reviewed-by: Andrey M. Borodin <x4mmm@yandex-team.ru> Discussion: https://postgr.es/m/CAFiTN-vzDvNz=ExGXz6gdyjtzGixKSqs0mKHMmaQ8sOSEFZ33A@mail.gmail.com
This commit is contained in:
@@ -689,9 +689,7 @@ ActivateCommitTs(void)
|
||||
/*
|
||||
* Re-Initialize our idea of the latest page number.
|
||||
*/
|
||||
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
|
||||
CommitTsCtl->shared->latest_page_number = pageno;
|
||||
LWLockRelease(CommitTsSLRULock);
|
||||
pg_atomic_write_u64(&CommitTsCtl->shared->latest_page_number, pageno);
|
||||
|
||||
/*
|
||||
* If CommitTs is enabled, but it wasn't in the previous server run, we
|
||||
@@ -1006,7 +1004,8 @@ commit_ts_redo(XLogReaderState *record)
|
||||
* During XLOG replay, latest_page_number isn't set up yet; insert a
|
||||
* suitable value to bypass the sanity test in SimpleLruTruncate.
|
||||
*/
|
||||
CommitTsCtl->shared->latest_page_number = trunc->pageno;
|
||||
pg_atomic_write_u64(&CommitTsCtl->shared->latest_page_number,
|
||||
trunc->pageno);
|
||||
|
||||
SimpleLruTruncate(CommitTsCtl, trunc->pageno);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user