Do not lock in BufferGetLSNAtomic() on archs with 8 byte atomic reads On platforms where we can read or write the whole LSN atomically, we do not need to lock the buffer header to prevent torn LSNs. We can do this only on platforms with PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY, and when the pd_lsn field is properly aligned.
For historical reasons the PageXLogRecPtr was defined as a struct with two uint32 fields. This replaces it with a single uint64 value, to make the intent clearer. To prevent issues with weak typedefs the value is still wrapped in a struct. This also adjusts heapfuncs() in pageinspect, to ensure proper alignment when reading the LSN from a page on alignment-sensitive hardware. Idea by Andres Freund. Initial patch by Andreas Karlsson, improved by Peter Geoghegan. Minor tweaks by me. Author: Andreas Karlsson <[email protected]> Author: Peter Geoghegan <[email protected]> Reviewed-by: Andres Freund <[email protected]> Reviewed-by: Tomas Vondra <[email protected]> Discussion: https://postgr.es/m/[email protected] Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/943e881733ca62ea2e1ceb20e79b3d149379755d Modified Files -------------- contrib/pageinspect/heapfuncs.c | 13 +++------- contrib/pageinspect/rawpage.c | 8 +++--- src/backend/access/common/bufmask.c | 2 +- src/backend/storage/buffer/bufmgr.c | 49 +++++++++++++++++++++++-------------- src/include/access/gist.h | 4 +-- src/include/storage/bufpage.h | 47 +++++++++++++++++++++++++++-------- 6 files changed, 76 insertions(+), 47 deletions(-)
