Skip to content

Commit 6379156

Browse files
committed
Log a better message when canceling autovacuum.
The old message was at DEBUG2, so typically it didn't show up in the log at all. As a result, in most cases where autovacuum was canceled, the only information that was logged was the table being vacuumed, with no indication as to what problem caused the cancel. Crank up the level to LOG and add some more details to assist with debugging. Back-patch all the way, per discussion on pgsql-hackers.
1 parent 2d7045d commit 6379156

File tree

1 file changed

+21
-4
lines changed
  • src/backend/storage/lmgr

1 file changed

+21
-4
lines changed

src/backend/storage/lmgr/proc.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -998,12 +998,29 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
998998
!(autovac->vacuumFlags & PROC_VACUUM_FOR_WRAPAROUND))
999999
{
10001000
int pid = autovac->pid;
1001+
StringInfoData locktagbuf;
1002+
StringInfoData logbuf; /* errdetail for server log */
1003+
1004+
initStringInfo(&locktagbuf);
1005+
initStringInfo(&logbuf);
1006+
DescribeLockTag(&locktagbuf, &lock->tag);
1007+
appendStringInfo(&logbuf,
1008+
_("Process %d waits for %s on %s"),
1009+
MyProcPid,
1010+
GetLockmodeName(lock->tag.locktag_lockmethodid,
1011+
lockmode),
1012+
locktagbuf.data);
1013+
1014+
/* release lock as quickly as possible */
1015+
LWLockRelease(ProcArrayLock);
10011016

1002-
elog(DEBUG2, "sending cancel to blocking autovacuum pid = %d",
1003-
pid);
1017+
ereport(LOG,
1018+
(errmsg("sending cancel to blocking autovacuum PID %d",
1019+
pid),
1020+
errdetail_log("%s", logbuf.data)));
10041021

1005-
/* don't hold the lock across the kill() syscall */
1006-
LWLockRelease(ProcArrayLock);
1022+
pfree(logbuf.data);
1023+
pfree(locktagbuf.data);
10071024

10081025
/* send the autovacuum worker Back to Old Kent Road */
10091026
if (kill(pid, SIGINT) < 0)

0 commit comments

Comments
 (0)