pgsql: Avoid atomic operation in MarkLocalBufferDirty().

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Avoid atomic operation in MarkLocalBufferDirty().
Date: 2016-04-13 22:29:43
Message-ID: E1aqTI7-0004RT-P0@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)1460431476(at)sss(dot)pgh(dot)pa(dot)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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2016-04-13 22:58:25 pgsql: Fix pg_dump so pg_upgrade'ing an extension with simple opfamilie
Previous Message Tom Lane 2016-04-13 22:12:11 pgsql: Widen amount-to-flush arguments of FileWriteback and callers.