Skip to content

Commit 116be6c

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 cfa928f commit 116be6c

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
@@ -1170,22 +1170,32 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
11701170
/* release lock as quickly as possible */
11711171
LWLockRelease(ProcArrayLock);
11721172

1173-
ereport(LOG,
1173+
/* send the autovacuum worker Back to Old Kent Road */
1174+
ereport(DEBUG1,
11741175
(errmsg("sending cancel to blocking autovacuum PID %d",
11751176
pid),
11761177
errdetail_log("%s", logbuf.data)));
11771178

1178-
pfree(logbuf.data);
1179-
pfree(locktagbuf.data);
1180-
1181-
/* send the autovacuum worker Back to Old Kent Road */
11821179
if (kill(pid, SIGINT) < 0)
11831180
{
1184-
/* Just a warning to allow multiple callers */
1185-
ereport(WARNING,
1186-
(errmsg("could not send signal to process %d: %m",
1187-
pid)));
1181+
/*
1182+
* There's a race condition here: once we release the
1183+
* ProcArrayLock, it's possible for the autovac worker to
1184+
* close up shop and exit before we can do the kill().
1185+
* Therefore, we do not whinge about no-such-process.
1186+
* Other errors such as EPERM could conceivably happen if
1187+
* the kernel recycles the PID fast enough, but such cases
1188+
* seem improbable enough that it's probably best to issue
1189+
* a warning if we see some other errno.
1190+
*/
1191+
if (errno != ESRCH)
1192+
ereport(WARNING,
1193+
(errmsg("could not send signal to process %d: %m",
1194+
pid)));
11881195
}
1196+
1197+
pfree(logbuf.data);
1198+
pfree(locktagbuf.data);
11891199
}
11901200
else
11911201
LWLockRelease(ProcArrayLock);

0 commit comments

Comments
 (0)