Indicate anti-wraparound autovacuum in log_autovacuum_min_duration

Started by Sergei Kornilovover 7 years ago11 messages
1 attachment(s)

Hello
Currently log_autovacuum_min_duration log message has no difference between regular autovacuum and to prevent wraparound autovacuum. There are important differences, for example, backend can automatically cancel regular autovacuum, but not anti-wraparound. I think it is useful indicate anti-wraparound in logs.

Small patch attached. I am not sure can be anti-wraparound autovacuum not aggressive, so i leave all 4 variants.

regards, Sergei

Attachments:

indicate_wraparound_in_log_autovacuum_min_duration_v1.patchtext/x-diff; name=indicate_wraparound_in_log_autovacuum_min_duration_v1.patchDownload
diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c
index 5649a70..5792854 100644
--- a/src/backend/commands/vacuumlazy.c
+++ b/src/backend/commands/vacuumlazy.c
@@ -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)),
#2Michael Paquier
michael@paquier.xyz
In reply to: Sergei Kornilov (#1)
Re: Indicate anti-wraparound autovacuum in log_autovacuum_min_duration

On Sat, Jul 21, 2018 at 09:38:38AM +0300, Sergei Kornilov wrote:

Currently log_autovacuum_min_duration log message has no difference
between regular autovacuum and to prevent wraparound autovacuum. There
are important differences, for example, backend can automatically
cancel regular autovacuum, but not anti-wraparound. I think it is
useful indicate anti-wraparound in logs.

Yes, a bit more verbosity would be nice for that. Using the term
"anti-wraparound" directly in the logs makes the most sense?

Small patch attached. I am not sure can be anti-wraparound autovacuum
not aggressive, so i leave all 4 variants.

The patch could be made simpler by using empty strings with a single
ereport() call.
--
Michael

In reply to: Michael Paquier (#2)
Re: Indicate anti-wraparound autovacuum in log_autovacuum_min_duration

Hello

Yes, a bit more verbosity would be nice for that. Using the term
"anti-wraparound" directly in the logs makes the most sense?

I used "(to prevent wraparound)" to looks like reporting in pg_stat_activity. As far i can see currently we not using "anti-wraparound" for user messages.
On the other hand we using anti-wraparound in docs, so i can change wording.

The patch could be made simpler by using empty strings with a single
ereport() call.

How about proper translate in this case? Currently we translate full line "automatic vacuum of table \"%s.%s.%s\": index scans: %d\n" before ereport call.

regards, Sergei

#4Robert Haas
robertmhaas@gmail.com
In reply to: Michael Paquier (#2)
Re: Indicate anti-wraparound autovacuum in log_autovacuum_min_duration

On Sat, Jul 21, 2018 at 4:22 AM, Michael Paquier <michael@paquier.xyz> wrote:

On Sat, Jul 21, 2018 at 09:38:38AM +0300, Sergei Kornilov wrote:

Currently log_autovacuum_min_duration log message has no difference
between regular autovacuum and to prevent wraparound autovacuum. There
are important differences, for example, backend can automatically
cancel regular autovacuum, but not anti-wraparound. I think it is
useful indicate anti-wraparound in logs.

Yes, a bit more verbosity would be nice for that. Using the term
"anti-wraparound" directly in the logs makes the most sense?

I'm not particularly in love with that terminology. I doubt that it's
very clear to the average user.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#5Masahiko Sawada
sawada.mshk@gmail.com
In reply to: Sergei Kornilov (#3)
Re: Indicate anti-wraparound autovacuum in log_autovacuum_min_duration

On Sat, Jul 21, 2018 at 6:26 PM, Sergei Kornilov <sk@zsrv.org> wrote:

Hello

Yes, a bit more verbosity would be nice for that. Using the term
"anti-wraparound" directly in the logs makes the most sense?

I used "(to prevent wraparound)" to looks like reporting in pg_stat_activity. As far i can see currently we not using "anti-wraparound" for user messages.
On the other hand we using anti-wraparound in docs, so i can change wording.

+1 for "to prevent wraparound".

The patch could be made simpler by using empty strings with a single
ereport() call.

How about proper translate in this case? Currently we translate full line "automatic vacuum of table \"%s.%s.%s\": index scans: %d\n" before ereport call.

Yeah, for translation I think it's better to make full lines. When we
added "aggressive" to autovacuum logs (commit b55509) we've done the
same thing.

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

#6Michael Paquier
michael@paquier.xyz
In reply to: Masahiko Sawada (#5)
Re: Indicate anti-wraparound autovacuum in log_autovacuum_min_duration

On Tue, Jul 24, 2018 at 06:02:00PM +0900, Masahiko Sawada wrote:

Yeah, for translation I think it's better to make full lines. When we
added "aggressive" to autovacuum logs (commit b55509) we've done the
same thing.

I am wondering if it would easier to add an extra line in the output,
like "Options: aggressive, wraparound prevention" or such...
--
Michael

#7Masahiko Sawada
sawada.mshk@gmail.com
In reply to: Michael Paquier (#6)
Re: Indicate anti-wraparound autovacuum in log_autovacuum_min_duration

On Tue, Jul 24, 2018 at 8:25 PM, Michael Paquier <michael@paquier.xyz> wrote:

On Tue, Jul 24, 2018 at 06:02:00PM +0900, Masahiko Sawada wrote:

Yeah, for translation I think it's better to make full lines. When we
added "aggressive" to autovacuum logs (commit b55509) we've done the
same thing.

I am wondering if it would easier to add an extra line in the output,
like "Options: aggressive, wraparound prevention" or such...

It would be useful if we have a number of the options autovacuum
workers could use but since there are only 2 I'm not sure we need the
list-style.

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

#8Michael Paquier
michael@paquier.xyz
In reply to: Masahiko Sawada (#7)
Re: Indicate anti-wraparound autovacuum in log_autovacuum_min_duration

On Wed, Sep 12, 2018 at 05:36:31PM +0900, Masahiko Sawada wrote:

It would be useful if we have a number of the options autovacuum
workers could use but since there are only 2 I'm not sure we need the
list-style.

Looking at what Sergei has proposed upthread again, using a
comma-separated list of options may be more painful for translators as
such lists really depend on the language, so I would be fine to commit
what has been added.

One last point though: we use anti-wraparound in already five places in
the docs, still I have sympathy for "to prevent wraparound" as well.
The brackets look rather useless to me, wouldn't it be better to remove
them? By doing so the longest message becomes:
"automatic aggressive vacuum to prevent wraparound of table blah.blah"
--
Michael

In reply to: Michael Paquier (#8)
1 attachment(s)
Re: Indicate anti-wraparound autovacuum in log_autovacuum_min_duration

Hello

The brackets look rather useless to me, wouldn't it be better to remove
them? By doing so the longest message becomes:
"automatic aggressive vacuum to prevent wraparound of table blah.blah"

Hmm,

2018-09-13 11:48:09.303 MSK 6994 @ from [vxid:6/713 txid:0] [] LOG: automatic aggressive vacuum (to prevent wraparound) of table "template0.pg_toast.pg_toast_12252": index scans: 0

or

2018-09-13 11:54:55.095 MSK 10115 @ from [vxid:3/100278 txid:0] [] LOG: automatic aggressive vacuum to prevent wraparound of table "template0.pg_toast.pg_toast_12252": index scans: 0

Looks better for me. Updated patch attached.

regards, Sergei

Attachments:

indicate_wraparound_in_log_autovacuum_min_duration_v2.patchtext/x-diff; name=indicate_wraparound_in_log_autovacuum_min_duration_v2.patchDownload
diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c
index 5649a70..8996d36 100644
--- a/src/backend/commands/vacuumlazy.c
+++ b/src/backend/commands/vacuumlazy.c
@@ -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)),
#10Michael Paquier
michael@paquier.xyz
In reply to: Sergei Kornilov (#9)
Re: Indicate anti-wraparound autovacuum in log_autovacuum_min_duration

On Thu, Sep 13, 2018 at 12:00:49PM +0300, Sergei Kornilov wrote:

Looks better for me. Updated patch attached.

Thanks Sergei for the new version, pushed.
--
Michael

In reply to: Michael Paquier (#10)
Re: Indicate anti-wraparound autovacuum in log_autovacuum_min_duration

Thanks Sergei for the new version, pushed.

Thank you!

regards, Sergei