• Andres Freund's avatar
    Avoid atomic operation in MarkLocalBufferDirty(). · 6b93fcd1
    Andres Freund authored
    The recent patch to make Pin/UnpinBuffer lockfree in the hot
    path (48354581), accidentally used pg_atomic_fetch_or_u32() in
    MarkLocalBufferDirty(). Other code operating on local buffers was
    careful to only use pg_atomic_read/write_u32 which just read/write from
    memory; to avoid unnecessary overhead.
    
    On its own that'd just make MarkLocalBufferDirty() slightly less
    efficient, but in addition InitLocalBuffers() doesn't call
    pg_atomic_init_u32() - thus the spinlock fallback for the atomic
    operations isn't initialized. That in turn caused, as reported by Tom,
    buildfarm animal gaur to fail.  As those errors are actually useful
    against this type of error, continue to omit - intentionally this time -
    initialization of the atomic variable.
    
    In addition, add an explicit note about only using pg_atomic_read/write
    on local buffers's state to BufferDesc's description.
    
    Reported-By: Tom Lane
    Discussion: 1881.1460431476@sss.pgh.pa.us
    6b93fcd1
buf_internals.h 12.2 KB