Skip to content

Commit f527c0a

Browse files
committed
Reduce chatter from signaling of autovacuum workers.
Don't print a WARNING if we get ESRCH from a kill() that's attempting to cancel an autovacuum worker. It's possible (and has been seen in the buildfarm) that the worker is already gone by the time we are able to execute the kill, in which case the failure is harmless. About the only plausible reason for reporting such cases would be to help debug corrupted lock table contents, but this is hardly likely to be the most important symptom if that happens. Moreover issuing a WARNING might scare users more than is warranted. Also, since sending a signal to an autovacuum worker is now entirely a routine thing, and the worker will log the query cancel on its end anyway, reduce the message saying we're doing that from LOG to DEBUG1 level. Very minor cosmetic cleanup as well. Since the main practical reason for doing this is to avoid unnecessary buildfarm failures, back-patch to all active branches.
1 parent 444b2eb commit f527c0a

File tree

1 file changed

+22
-12
lines changed
  • src/backend/storage/lmgr

1 file changed

+22
-12
lines changed

src/backend/storage/lmgr/proc.c

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,22 +1033,32 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
10331033
/* release lock as quickly as possible */
10341034
LWLockRelease(ProcArrayLock);
10351035

1036-
ereport(LOG,
1037-
(errmsg("sending cancel to blocking autovacuum PID %d",
1038-
pid),
1039-
errdetail_log("%s", logbuf.data)));
1040-
1041-
pfree(logbuf.data);
1042-
pfree(locktagbuf.data);
1043-
10441036
/* send the autovacuum worker Back to Old Kent Road */
1037+
ereport(DEBUG1,
1038+
(errmsg("sending cancel to blocking autovacuum PID %d",
1039+
pid),
1040+
errdetail_log("%s", logbuf.data)));
1041+
10451042
if (kill(pid, SIGINT) < 0)
10461043
{
1047-
/* Just a warning to allow multiple callers */
1048-
ereport(WARNING,
1049-
(errmsg("could not send signal to process %d: %m",
1050-
pid)));
1044+
/*
1045+
* There's a race condition here: once we release the
1046+
* ProcArrayLock, it's possible for the autovac worker to
1047+
* close up shop and exit before we can do the kill().
1048+
* Therefore, we do not whinge about no-such-process.
1049+
* Other errors such as EPERM could conceivably happen if
1050+
* the kernel recycles the PID fast enough, but such cases
1051+
* seem improbable enough that it's probably best to issue
1052+
* a warning if we see some other errno.
1053+
*/
1054+
if (errno != ESRCH)
1055+
ereport(WARNING,
1056+
(errmsg("could not send signal to process %d: %m",
1057+
pid)));
10511058
}
1059+
1060+
pfree(logbuf.data);
1061+
pfree(locktagbuf.data);
10521062
}
10531063
else
10541064
LWLockRelease(ProcArrayLock);

0 commit comments

Comments
 (0)