Skip to content

Commit 87a3023

Browse files
committed
Move memory barrier in UnlockBufHdr to before releasing the lock.
This bug appears to have been introduced late in the development of 4835458 ("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: -
1 parent 975ad4e commit 87a3023

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/include/storage/buf_internals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ extern PGDLLIMPORT LWLockMinimallyPadded *BufferIOLWLockArray;
242242
extern uint32 LockBufHdr(BufferDesc *desc);
243243
#define UnlockBufHdr(desc, s) \
244244
do { \
245-
pg_atomic_write_u32(&(desc)->state, (s) & (~BM_LOCKED)); \
246245
pg_write_barrier(); \
246+
pg_atomic_write_u32(&(desc)->state, (s) & (~BM_LOCKED)); \
247247
} while (0)
248248

249249

0 commit comments

Comments
 (0)