On Fri, Dec 17, 2010 at 4:17 PM, Tom Lane <t...@sss.pgh.pa.us> wrote: >> Since these bits will only be set/cleared when the buffer mapping is >> changed, can we examine this bit without taking the spinlock? > > Only if you're willing for the result to be unreliable.
If we read the bits while someone else is writing them, we'll get either the old or the new value, but the BM_FLUSH_XLOG bit will be the same either way. When FlushBuffer() is called, a shared content log and a pin are held, so the buffer can't be renamed under us. If that's really unacceptable, we can do something like the attached, but I think this is unnecessarily gross. We already assume in other places that the read or write of an integer is atomic. In this case we don't even need it to be fully atomic - we just need the particular byte that contains this bit not to go through some intermediate state where the bit is unset. Is there really a memory architecture out there that's crazy enough to let such a thing happen? If so, I'd expect things to be breaking right and left on that machine anyway. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
bm-flush-xlog-paranoid.patch
Description: Binary data
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers