1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-16 06:01:02 +03:00

Repair a low-probability race condition identified by Qingqing Zhou.

If a process abandons a wait in LockBufferForCleanup (in practice,
only happens if someone cancels a VACUUM) just before someone else
sends it a signal indicating the buffer is available, it was possible
for the wakeup to remain in the process' semaphore, causing misbehavior
next time the process waited for an lmgr lock.  Rather than try to
prevent the race condition directly, it seems best to make the lock
manager robust against leftover wakeups, by having it repeat waiting
on the semaphore if the lock has not actually been granted or denied
yet.
This commit is contained in:
Tom Lane
2006-04-14 03:38:56 +00:00
parent cc39aca7d4
commit 0fcc3c2f1d
5 changed files with 44 additions and 53 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.206 2006/03/31 23:32:06 tgl Exp $
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.207 2006/04/14 03:38:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -1726,8 +1726,6 @@ UnlockBuffers(void)
if (buf)
{
HOLD_INTERRUPTS(); /* don't want to die() partway through... */
LockBufHdr(buf);
/*
@ -1740,11 +1738,7 @@ UnlockBuffers(void)
UnlockBufHdr(buf);
ProcCancelWaitForSignal();
PinCountWaitBuf = NULL;
RESUME_INTERRUPTS();
}
}