Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e0d97d7

Browse files
committed
Fix deadlock with LWLockAcquireWithVar and LWLockWaitForVar.
LWLockRelease should release all backends waiting with LWLockWaitForVar, even when another backend has already been woken up to acquire the lock, i.e. when releaseOK is false. LWLockWaitForVar can return as soon as the protected value changes, even if the other backend will acquire the lock. Fix that by resetting releaseOK to true in LWLockWaitForVar, whenever adding itself to the wait queue. This should fix the bug reported by MauMau, where the system occasionally hangs when there is a lot of concurrent WAL activity and a checkpoint. Backpatch to 9.4, where this code was added.
1 parent 0ff5047 commit e0d97d7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/backend/storage/lmgr/lwlock.c

+6
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,12 @@ LWLockWaitForVar(LWLock *lock, uint64 *valptr, uint64 oldval, uint64 *newval)
10051005
lock->tail = proc;
10061006
lock->head = proc;
10071007

1008+
/*
1009+
* Set releaseOK, to make sure we get woken up as soon as the lock is
1010+
* released.
1011+
*/
1012+
lock->releaseOK = true;
1013+
10081014
/* Can release the mutex now */
10091015
SpinLockRelease(&lock->mutex);
10101016

0 commit comments

Comments
 (0)