]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Log a better message when canceling autovacuum.
authorRobert Haas <rhaas@postgresql.org>
Thu, 26 Jul 2012 13:16:44 +0000 (09:16 -0400)
committerRobert Haas <rhaas@postgresql.org>
Thu, 26 Jul 2012 13:17:17 +0000 (09:17 -0400)
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

index 3248e136c9a7acba6aa0e7322b1c6c59321aec00..00c4a562a9d1a503a5a09590e3970a0d200dd907 100644 (file)
@@ -917,12 +917,29 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
                                !(autovac->vacuumFlags & PROC_VACUUM_FOR_WRAPAROUND))
                        {
                                int                     pid = autovac->pid;
+                               StringInfoData locktagbuf;
+                               StringInfoData logbuf;          /* errdetail for server log */
+
+                               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);
+
+                               /* release lock as quickly as possible */
+                               LWLockRelease(ProcArrayLock);
 
-                               elog(DEBUG2, "sending cancel to blocking autovacuum pid = %d",
-                                        pid);
+                               ereport(LOG,
+                                               (errmsg("sending cancel to blocking autovacuum PID %d",
+                                                       pid),
+                                                errdetail_log("%s", logbuf.data)));
 
-                               /* don't hold the lock across the kill() syscall */
-                               LWLockRelease(ProcArrayLock);
+                               pfree(logbuf.data);
+                               pfree(locktagbuf.data);
 
                                /* send the autovacuum worker Back to Old Kent Road */
                                if (kill(pid, SIGINT) < 0)