Skip to content

Commit 47ee275

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 48d23c7 commit 47ee275

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
@@ -1183,22 +1183,32 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
11831183
/* release lock as quickly as possible */
11841184
LWLockRelease(ProcArrayLock);
11851185

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

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

0 commit comments

Comments
 (0)