Merge pull request #1809 from citusdata/get_rid_of_false_positives

Get rid of some of the false positive distributed deadlocks
pull/1810/head
Önder Kalacı 2017-11-15 16:13:57 +03:00 committed by GitHub
commit 666e37273a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 6 deletions

View File

@ -494,7 +494,11 @@ BuildLocalWaitGraph(void)
/*
* IsProcessWaitingForSafeOperations returns true if the given PROC
* waiting on relation extension lock or page locks.
* waiting on relation extension locks, page locks or speculative locks.
*
* The function also returns true if the waiting process is an autovacuum
* process given that autovacuum cannot contribute to any distributed
* deadlocks.
*
* In general for the purpose of distributed deadlock detection, we should
* skip if the process blocked on the locks that may not be part of deadlocks.
@ -509,17 +513,26 @@ IsProcessWaitingForSafeOperations(PGPROC *proc)
{
PROCLOCK *waitProcLock = NULL;
LOCK *waitLock = NULL;
PGXACT *pgxact = NULL;
if (proc->waitStatus != STATUS_WAITING)
{
return false;
}
/* get the transaction that the backend associated with */
pgxact = &ProcGlobal->allPgXact[proc->pgprocno];
if (pgxact->vacuumFlags & PROC_IS_AUTOVACUUM)
{
return true;
}
waitProcLock = proc->waitProcLock;
waitLock = waitProcLock->tag.myLock;
return waitLock->tag.locktag_type == LOCKTAG_RELATION_EXTEND ||
waitLock->tag.locktag_type == LOCKTAG_PAGE;
waitLock->tag.locktag_type == LOCKTAG_PAGE ||
waitLock->tag.locktag_type == LOCKTAG_SPECULATIVE_TOKEN;
}
@ -596,8 +609,7 @@ AddEdgesForLockWaits(WaitGraph *waitGraph, PGPROC *waitingProc, PROCStack *remai
/*
* Skip processes from the same lock group, processes that don't conflict,
* and processes that are waiting on a relation extension lock or page locks,
* which will be released shortly.
* and processes that are waiting on safe operations.
*/
if (!IsSameLockGroup(waitingProc, currentProc) &&
IsConflictingLockMask(procLock->holdMask, conflictMask) &&
@ -641,8 +653,7 @@ AddEdgesForWaitQueue(WaitGraph *waitGraph, PGPROC *waitingProc, PROCStack *remai
/*
* Skip processes from the same lock group, processes that don't conflict,
* and processes that are waiting on a relation extension lock or page locks,
* which will be released shortly.
* and processes that are waiting on safe operations.
*/
if (!IsSameLockGroup(waitingProc, currentProc) &&
IsConflictingLockMask(awaitMask, conflictMask) &&