Skip to content

Commit 5a24efd

Browse files
anarazelAlexander Korotkov
authored and
Alexander Korotkov
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 73adc14 commit 5a24efd

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
@@ -230,8 +230,8 @@ typedef union BufferDescPadded
230230
extern uint32 LockBufHdr(BufferDesc *desc);
231231
#define UnlockBufHdr(desc, s) \
232232
do { \
233-
pg_atomic_write_u32(&(desc)->state, (s) & (~BM_LOCKED)); \
234233
pg_write_barrier(); \
234+
pg_atomic_write_u32(&(desc)->state, (s) & (~BM_LOCKED)); \
235235
} while (0)
236236

237237

0 commit comments

Comments
 (0)