Improve autovacuum logging for aggressive and anti-wraparound runs
authorMichael Paquier <michael@paquier.xyz>
Thu, 13 Sep 2018 22:35:39 +0000 (07:35 +0900)
committerMichael Paquier <michael@paquier.xyz>
Thu, 13 Sep 2018 22:35:39 +0000 (07:35 +0900)
A log message was being generated when log_min_duration is reached for
autovacuum on a given relation to indicate if it was an aggressive run,
and missed the point of mentioning if it is doing an anti-wrapround
run.  The log message generated is improved so as one, both or no extra
details are added depending on the option set.

Author: Sergei Kornilov
Reviewed-by: Masahiko Sawada, Michael Paquier
Discussion: https://postgr.es/m/11587951532155118@sas1-19a94364928d.qloud-c.yandex.net

src/backend/commands/vacuumlazy.c

index 5649a70800db3e4ab061edfb7bec4de142d0cb80..8996d366e91157591fa7cb47285e48d91f142487 100644 (file)
@@ -374,10 +374,20 @@ lazy_vacuum_rel(Relation onerel, int options, VacuumParams *params,
             * emitting individual parts of the message when not applicable.
             */
            initStringInfo(&buf);
-           if (aggressive)
-               msgfmt = _("automatic aggressive vacuum of table \"%s.%s.%s\": index scans: %d\n");
+           if (params->is_wraparound)
+           {
+               if (aggressive)
+                   msgfmt = _("automatic aggressive vacuum to prevent wraparound of table \"%s.%s.%s\": index scans: %d\n");
+               else
+                   msgfmt = _("automatic vacuum to prevent wraparound of table \"%s.%s.%s\": index scans: %d\n");
+           }
            else
-               msgfmt = _("automatic vacuum of table \"%s.%s.%s\": index scans: %d\n");
+           {
+               if (aggressive)
+                   msgfmt = _("automatic aggressive vacuum of table \"%s.%s.%s\": index scans: %d\n");
+               else
+                   msgfmt = _("automatic vacuum of table \"%s.%s.%s\": index scans: %d\n");
+           }
            appendStringInfo(&buf, msgfmt,
                             get_database_name(MyDatabaseId),
                             get_namespace_name(RelationGetNamespace(onerel)),