pgsql: Avoid atomic operation in MarkLocalBufferDirty(). - Mailing list pgsql-committers

From Andres Freund
Subject pgsql: Avoid atomic operation in MarkLocalBufferDirty().
Date
Msg-id E1aqTI7-0004RT-P0@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Avoid atomic operation in MarkLocalBufferDirty().

The recent patch to make Pin/UnpinBuffer lockfree in the hot
path (48354581a), 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

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/6b93fcd149329d4ee7319561b30fc15a573c6307

Modified Files
--------------
src/backend/storage/buffer/localbuf.c | 13 ++++++++++++-
src/include/storage/buf_internals.h   |  6 ++++--
2 files changed, 16 insertions(+), 3 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Widen amount-to-flush arguments of FileWriteback and callers.
Next
From: Tom Lane
Date:
Subject: pgsql: Fix pg_dump so pg_upgrade'ing an extension with simple opfamilie