Commit 87a3023c authored by Andres Freund's avatar Andres Freund

Move memory barrier in UnlockBufHdr to before releasing the lock.

This bug appears to have been introduced late in the development of
48354581 ("Allow Pin/UnpinBuffer to operate in a lockfree
manner.").

Found while debugging a bug which turned out to be independent of the
commit mentioned above.

Backpatch: -
parent 975ad4e6
...@@ -242,8 +242,8 @@ extern PGDLLIMPORT LWLockMinimallyPadded *BufferIOLWLockArray; ...@@ -242,8 +242,8 @@ extern PGDLLIMPORT LWLockMinimallyPadded *BufferIOLWLockArray;
extern uint32 LockBufHdr(BufferDesc *desc); extern uint32 LockBufHdr(BufferDesc *desc);
#define UnlockBufHdr(desc, s) \ #define UnlockBufHdr(desc, s) \
do { \ do { \
pg_atomic_write_u32(&(desc)->state, (s) & (~BM_LOCKED)); \
pg_write_barrier(); \ pg_write_barrier(); \
pg_atomic_write_u32(&(desc)->state, (s) & (~BM_LOCKED)); \
} while (0) } while (0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment