Skip to content

Commit a5bca24

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 ba98239 commit a5bca24

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
@@ -1100,12 +1100,29 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
11001100
!(autovac_pgxact->vacuumFlags & PROC_VACUUM_FOR_WRAPAROUND))
11011101
{
11021102
int pid = autovac->pid;
1103+
StringInfoData locktagbuf;
1104+
StringInfoData logbuf; /* errdetail for server log */
1105+
1106+
initStringInfo(&locktagbuf);
1107+
initStringInfo(&logbuf);
1108+
DescribeLockTag(&locktagbuf, &lock->tag);
1109+
appendStringInfo(&logbuf,
1110+
_("Process %d waits for %s on %s"),
1111+
MyProcPid,
1112+
GetLockmodeName(lock->tag.locktag_lockmethodid,
1113+
lockmode),
1114+
locktagbuf.data);
1115+
1116+
/* release lock as quickly as possible */
1117+
LWLockRelease(ProcArrayLock);
11031118

1104-
elog(DEBUG2, "sending cancel to blocking autovacuum PID %d",
1105-
pid);
1119+
ereport(LOG,
1120+
(errmsg("sending cancel to blocking autovacuum PID %d",
1121+
pid),
1122+
errdetail_log("%s", logbuf.data)));
11061123

1107-
/* don't hold the lock across the kill() syscall */
1108-
LWLockRelease(ProcArrayLock);
1124+
pfree(logbuf.data);
1125+
pfree(locktagbuf.data);
11091126

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

0 commit comments

Comments
 (0)