From 63791569d8d7c01257e8f85fdbb918d144e54cc6 Mon Sep 17 00:00:00 2001 From: Robert Haas <rhaas@postgresql.org> Date: Thu, 26 Jul 2012 09:16:44 -0400 Subject: [PATCH] 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. --- src/backend/storage/lmgr/proc.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 8896f6c2db..45e435c31b 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -998,13 +998,30 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable) !(autovac->vacuumFlags & PROC_VACUUM_FOR_WRAPAROUND)) { int pid = autovac->pid; + StringInfoData locktagbuf; + StringInfoData logbuf; /* errdetail for server log */ - elog(DEBUG2, "sending cancel to blocking autovacuum pid = %d", - pid); + initStringInfo(&locktagbuf); + initStringInfo(&logbuf); + DescribeLockTag(&locktagbuf, &lock->tag); + appendStringInfo(&logbuf, + _("Process %d waits for %s on %s"), + MyProcPid, + GetLockmodeName(lock->tag.locktag_lockmethodid, + lockmode), + locktagbuf.data); - /* don't hold the lock across the kill() syscall */ + /* release lock as quickly as possible */ LWLockRelease(ProcArrayLock); + ereport(LOG, + (errmsg("sending cancel to blocking autovacuum PID %d", + pid), + errdetail_log("%s", logbuf.data))); + + pfree(logbuf.data); + pfree(locktagbuf.data); + /* send the autovacuum worker Back to Old Kent Road */ if (kill(pid, SIGINT) < 0) {