Skip to content

Commit 082d428

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 ab60847 commit 082d428

File tree

1 file changed

+19
-9
lines changed
  • src/backend/storage/lmgr

1 file changed

+19
-9
lines changed

src/backend/storage/lmgr/proc.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,22 +1185,32 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
11851185
/* release lock as quickly as possible */
11861186
LWLockRelease(ProcArrayLock);
11871187

1188-
ereport(LOG,
1188+
/* send the autovacuum worker Back to Old Kent Road */
1189+
ereport(DEBUG1,
11891190
(errmsg("sending cancel to blocking autovacuum PID %d",
11901191
pid),
11911192
errdetail_log("%s", logbuf.data)));
11921193

1193-
pfree(logbuf.data);
1194-
pfree(locktagbuf.data);
1195-
1196-
/* send the autovacuum worker Back to Old Kent Road */
11971194
if (kill(pid, SIGINT) < 0)
11981195
{
1199-
/* Just a warning to allow multiple callers */
1200-
ereport(WARNING,
1201-
(errmsg("could not send signal to process %d: %m",
1202-
pid)));
1196+
/*
1197+
* There's a race condition here: once we release the
1198+
* ProcArrayLock, it's possible for the autovac worker to
1199+
* close up shop and exit before we can do the kill().
1200+
* Therefore, we do not whinge about no-such-process.
1201+
* Other errors such as EPERM could conceivably happen if
1202+
* the kernel recycles the PID fast enough, but such cases
1203+
* seem improbable enough that it's probably best to issue
1204+
* a warning if we see some other errno.
1205+
*/
1206+
if (errno != ESRCH)
1207+
ereport(WARNING,
1208+
(errmsg("could not send signal to process %d: %m",
1209+
pid)));
12031210
}
1211+
1212+
pfree(logbuf.data);
1213+
pfree(locktagbuf.data);
12041214
}
12051215
else
12061216
LWLockRelease(ProcArrayLock);

0 commit comments

Comments
 (0)