mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
Fix for deadlock timer timeout.
This commit is contained in:
parent
550de5db2c
commit
f659ec545f
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.44 1998/12/18 19:45:37 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.45 1998/12/29 18:29:18 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -46,7 +46,7 @@
|
|||||||
* This is so that we can support more backends. (system-wide semaphore
|
* This is so that we can support more backends. (system-wide semaphore
|
||||||
* sets run out pretty fast.) -ay 4/95
|
* sets run out pretty fast.) -ay 4/95
|
||||||
*
|
*
|
||||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.44 1998/12/18 19:45:37 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.45 1998/12/29 18:29:18 momjian Exp $
|
||||||
*/
|
*/
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -449,7 +449,6 @@ ProcSleep(PROC_QUEUE *waitQueue,/* lock->waitProcs */
|
|||||||
int i;
|
int i;
|
||||||
bool deadlock_checked = false;
|
bool deadlock_checked = false;
|
||||||
PROC *proc;
|
PROC *proc;
|
||||||
struct timeval timeval;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the first entries in the waitQueue have a greater priority than
|
* If the first entries in the waitQueue have a greater priority than
|
||||||
@ -513,29 +512,24 @@ ProcSleep(PROC_QUEUE *waitQueue,/* lock->waitProcs */
|
|||||||
SpinRelease(spinlock);
|
SpinRelease(spinlock);
|
||||||
|
|
||||||
/* --------------
|
/* --------------
|
||||||
* We set this so we can wake up periodically and check for a deadlock.
|
* We set this so we can wake up after one second to check for a deadlock.
|
||||||
* If a deadlock is detected, the handler releases the processes
|
* If a deadlock is detected, the handler releases the processes
|
||||||
* semaphore and aborts the current transaction.
|
* semaphore and aborts the current transaction.
|
||||||
*
|
|
||||||
* Need to zero out struct to set the interval and the micro seconds fields
|
|
||||||
* to 0.
|
|
||||||
* --------------
|
* --------------
|
||||||
*/
|
*/
|
||||||
MemSet(&timeval, 0, sizeof(struct timeval));
|
|
||||||
timeval.tv_sec = \
|
|
||||||
(DeadlockCheckTimer ? DeadlockCheckTimer : DEADLOCK_CHECK_TIMER);
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
int expire;
|
int expired;
|
||||||
|
|
||||||
MyProc->errType = NO_ERROR; /* reset flag after deadlock check */
|
MyProc->errType = NO_ERROR; /* reset flag after deadlock check */
|
||||||
|
|
||||||
if ((expire = select(0, NULL, NULL, NULL,
|
if (deadlock_checked == false)
|
||||||
(deadlock_checked == false) ? &timeval : NULL)) == -1)
|
expired = sleep(DeadlockCheckTimer ? DeadlockCheckTimer : DEADLOCK_CHECK_TIMER);
|
||||||
elog(FATAL, "ProcSleep: Unable to set timer for process wakeup");
|
else
|
||||||
|
pause();
|
||||||
|
|
||||||
if (expire == 0 /* timeout reached */ && deadlock_checked == false)
|
if (expired == 0 && deadlock_checked == false)
|
||||||
{
|
{
|
||||||
HandleDeadLock();
|
HandleDeadLock();
|
||||||
deadlock_checked = true;
|
deadlock_checked = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user