mirror of
https://github.com/postgres/postgres.git
synced 2025-06-03 00:02:26 -04:00
Additional write barrier in AdvanceXLInsertBuffer().
First, mark the xlblocks member with InvalidXLogRecPtr, then issue a write barrier, then initialize it. That ensures that the xlblocks member doesn't appear valid while the contents are being initialized. In preparation for reading WAL buffer contents without a lock. Author: Bharath Rupireddy Discussion: https://postgr.es/m/CALj2ACVfFMfqD5oLzZSQQZWfXiJqd-NdX0_317veP6FuB31QWA@mail.gmail.com Reviewed-by: Andres Freund
This commit is contained in:
parent
c3a8e2a7cb
commit
766571be16
@ -1932,6 +1932,14 @@ AdvanceXLInsertBuffer(XLogRecPtr upto, TimeLineID tli, bool opportunistic)
|
||||
|
||||
NewPage = (XLogPageHeader) (XLogCtl->pages + nextidx * (Size) XLOG_BLCKSZ);
|
||||
|
||||
/*
|
||||
* Mark the xlblock with InvalidXLogRecPtr and issue a write barrier
|
||||
* before initializing. Otherwise, the old page may be partially
|
||||
* zeroed but look valid.
|
||||
*/
|
||||
pg_atomic_write_u64(&XLogCtl->xlblocks[nextidx], InvalidXLogRecPtr);
|
||||
pg_write_barrier();
|
||||
|
||||
/*
|
||||
* Be sure to re-zero the buffer so that bytes beyond what we've
|
||||
* written will look like zeroes and not valid XLOG records...
|
||||
|
Loading…
x
Reference in New Issue
Block a user