mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Fix a variety of locking problems like newer lock waiters getting
lock before older waiters, and having readlock people not share locks if a writer is waiting for a lock, and waiting writers not getting priority over waiting readers.
This commit is contained in:
parent
1de8926bbe
commit
0e8ac82c63
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.19 1998/01/23 06:01:03 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.20 1998/01/23 22:16:46 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Outside modules can create a lock table and acquire/release
|
||||
@ -708,6 +708,20 @@ LockResolveConflicts(LOCKTAB *ltable,
|
||||
result->nHolding = 0;
|
||||
}
|
||||
|
||||
{
|
||||
/* ------------------------
|
||||
* If someone with a greater priority is waiting for the lock,
|
||||
* do not continue and share the lock, even if we can. bjm
|
||||
* ------------------------
|
||||
*/
|
||||
int myprio = ltable->ctl->prio[lockt];
|
||||
PROC_QUEUE *waitQueue = &(lock->waitProcs);
|
||||
PROC *topproc = (PROC *) MAKE_PTR(waitQueue->links.prev);
|
||||
|
||||
if (waitQueue->size && topproc->prio > myprio)
|
||||
return STATUS_FOUND;
|
||||
}
|
||||
|
||||
/* ----------------------------
|
||||
* first check for global conflicts: If no locks conflict
|
||||
* with mine, then I get the lock.
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.26 1998/01/23 06:01:05 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.27 1998/01/23 22:16:48 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -46,7 +46,7 @@
|
||||
* This is so that we can support more backends. (system-wide semaphore
|
||||
* sets run out pretty fast.) -ay 4/95
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.26 1998/01/23 06:01:05 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.27 1998/01/23 22:16:48 momjian Exp $
|
||||
*/
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
@ -469,7 +469,7 @@ ProcSleep(PROC_QUEUE *queue,
|
||||
proc = (PROC *) MAKE_PTR(queue->links.prev);
|
||||
for (i = 0; i < queue->size; i++)
|
||||
{
|
||||
if (proc->prio < prio)
|
||||
if (proc->prio >= prio)
|
||||
proc = (PROC *) MAKE_PTR(proc->links.prev);
|
||||
else
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user