diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index cac061f6661..1f7b725e6de 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -1149,22 +1149,32 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable) /* release lock as quickly as possible */ LWLockRelease(ProcArrayLock); - ereport(LOG, - (errmsg("sending cancel to blocking autovacuum PID %d", - pid), - errdetail_log("%s", logbuf.data))); + /* send the autovacuum worker Back to Old Kent Road */ + ereport(DEBUG1, + (errmsg("sending cancel to blocking autovacuum PID %d", + pid), + errdetail_log("%s", logbuf.data))); + + if (kill(pid, SIGINT) < 0) + { + /* + * There's a race condition here: once we release the + * ProcArrayLock, it's possible for the autovac worker to + * close up shop and exit before we can do the kill(). + * Therefore, we do not whinge about no-such-process. + * Other errors such as EPERM could conceivably happen if + * the kernel recycles the PID fast enough, but such cases + * seem improbable enough that it's probably best to issue + * a warning if we see some other errno. + */ + if (errno != ESRCH) + ereport(WARNING, + (errmsg("could not send signal to process %d: %m", + pid))); + } pfree(logbuf.data); pfree(locktagbuf.data); - - /* send the autovacuum worker Back to Old Kent Road */ - if (kill(pid, SIGINT) < 0) - { - /* Just a warning to allow multiple callers */ - ereport(WARNING, - (errmsg("could not send signal to process %d: %m", - pid))); - } } else LWLockRelease(ProcArrayLock);