]> granicus.if.org Git - postgresql/commit
Avoid atomic operation in MarkLocalBufferDirty().
authorAndres Freund <andres@anarazel.de>
Wed, 13 Apr 2016 22:28:29 +0000 (15:28 -0700)
committerAndres Freund <andres@anarazel.de>
Wed, 13 Apr 2016 22:28:29 +0000 (15:28 -0700)
commit6b93fcd149329d4ee7319561b30fc15a573c6307
tree89ff94e710d7cbab57cd7262139cca220c562f06
parent95ef43c4308102d23afa887c9fc28d9977612a2d
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
src/backend/storage/buffer/localbuf.c
src/include/storage/buf_internals.h