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

Commit 7949cd7

Browse files
committed
Applied K.Knizhnik's deadlock patch
1 parent a4dd374 commit 7949cd7

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/backend/storage/lmgr/proc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ InitProcGlobal(void)
186186
ProcGlobal->walwriterLatch = NULL;
187187
ProcGlobal->checkpointerLatch = NULL;
188188
pg_atomic_init_u32(&ProcGlobal->procArrayGroupFirst, INVALID_PGPROCNO);
189+
pg_atomic_init_flag(&ProcGlobal->activeDeadlockCheck);
189190

190191
/*
191192
* Create and initialize all the PGPROC structures we'll need. There are
@@ -1657,6 +1658,10 @@ CheckDeadLock(void)
16571658
{
16581659
int i;
16591660

1661+
1662+
if (!pg_atomic_test_set_flag(&ProcGlobal->activeDeadlockCheck))
1663+
return;
1664+
16601665
/*
16611666
* Acquire exclusive lock on the entire shared lock data structures. Must
16621667
* grab LWLocks in partition-number order to avoid LWLock deadlock.
@@ -1732,6 +1737,8 @@ CheckDeadLock(void)
17321737
check_done:
17331738
for (i = NUM_LOCK_PARTITIONS; --i >= 0;)
17341739
LWLockRelease(LockHashPartitionLockByIndex(i));
1740+
1741+
pg_atomic_clear_flag(&ProcGlobal->activeDeadlockCheck);
17351742
}
17361743

17371744
/*

src/include/storage/proc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ typedef struct PROC_HDR
253253
int startupProcPid;
254254
/* Buffer id of the buffer that Startup process waits for pin on, or -1 */
255255
int startupBufferPinWaitBufId;
256+
/* Deadlock detection is in progress */
257+
pg_atomic_flag activeDeadlockCheck;
256258
} PROC_HDR;
257259

258260
extern PGDLLIMPORT PROC_HDR *ProcGlobal;

0 commit comments

Comments
 (0)