[PATCH] pg_walsummary: suppress limit output with --quiet

Started by Koshi Shibagaki (Fujitsu)about 2 months ago10 messageshackers
Jump to latest
#1Koshi Shibagaki (Fujitsu)
shibagaki.koshi@fujitsu.com

Hi,

I noticed that pg_walsummary can still print limit lines when --quiet is
specified. This happens with summaries containing relation creation or
truncation, for example:

$ pg_walsummary --quiet example.summary
TS 1663, DB 5, REL 16387, FORK main: limit 0

If I understand correctly, --quiet should suppress
all output except errors.

In dump_one_relation(), the limit line is printed before the existing
quiet check. The attached patch adds a quiet check to that output while
preserving parsing and error detection.

The patch also adds TAP coverage for -q and --quiet and checks that a
truncated input file is still rejected. The pg_walsummary tests pass
with the patch.

Feedback would be appreciated.

Koshi Shibagaki
FUJITSU LIMITED
https://www.fujitsu.com/

Attachments:

t254056_1
v1-0001-pg_walsummary-quiet.patchapplication/octet-stream; name=v1-0001-pg_walsummary-quiet.patchDownload+32-1
#2Fujii Masao
masao.fujii@gmail.com
In reply to: Koshi Shibagaki (Fujitsu) (#1)
Re: [PATCH] pg_walsummary: suppress limit output with --quiet

On Mon, Oct 5, 2026 at 12:23 PM Koshi Shibagaki (Fujitsu)
<shibagaki.koshi@fujitsu.com> wrote:

Feedback would be appreciated.

Thanks for the patch!

+for my $option ('-q', '--quiet')

Testing both forms with the same input and expected output seems a bit
overkill for this fix, since both set the same flag. Isn't testing just
one of them be sufficient?

+# Quiet mode must still parse every file, including the final checksum.

Isn't this primarily adding test coverage for existing quiet-mode behavior,
rather than testing the bug being fixed? If so, it might be better to leave
this out of the bug-fix patch intended for backpatching. Thought?

Also, this fix should be backpatched to v17, where pg_walsummary was
introduced?

Regards,

--
Fujii Masao

#3Hayato Kuroda (Fujitsu)
kuroda.hayato@fujitsu.com
In reply to: Koshi Shibagaki (Fujitsu) (#1)
RE: [PATCH] pg_walsummary: suppress limit output with --quiet

Hi Shibagaki-san,

Good catch!

In dump_one_relation(), the limit line is printed before the existing
quiet check. The attached patch adds a quiet check to that output while
preserving parsing and error detection.

It might be matter of taste, but how about moving printf() after the `if (opt->quiet)`?
The code might be clearer.

The patch also adds TAP coverage for -q and --quiet and checks that a
truncated input file is still rejected. The pg_walsummary tests pass
with the patch.

```
+# --quiet must also suppress limit blocks caused by relation creation.
+my $summary_dir = $node1->data_dir . '/pg_wal/summaries';
+my @summaries = map { "$summary_dir/$_" }
+  sort grep { /^[0-9A-F]{40}\.summary$/ } slurp_dir($summary_dir);
+command_like(
+	[ 'pg_walsummary', @summaries ],
+	qr/: limit 0$/m,
+	'relation creation produces limit blocks');
+for my $option ('-q', '--quiet')
+{
+	command_checks_all(
+		[ 'pg_walsummary', $option, @summaries ],
+		0,
+		[qr/\A\z/],
+		[qr/\A\z/],
+		"$option suppresses all output");
+}
```

I feel it's enough to call command_checks_all() once, thought?

Best regards,
Hayato Kuroda
FUJITSU LIMITED

#4Koshi Shibagaki (Fujitsu)
shibagaki.koshi@fujitsu.com
In reply to: Hayato Kuroda (Fujitsu) (#3)
Re: [PATCH] pg_walsummary: suppress limit output with --quiet

Fujii-san, Kuroda-san,

Thank you both for reviewing the patch.

Testing both forms with the same input and expected output seems a bit
overkill for this fix, since both set the same flag. Isn't testing just
one of them be sufficient?

I feel it's enough to call command_checks_all() once, thought?

Agreed. In v2, I kept only the -q test, so command_checks_all() is
called once.

Isn't this primarily adding test coverage for existing quiet-mode behavior,
rather than testing the bug being fixed? If so, it might be better to leave
this out of the bug-fix patch intended for backpatching. Thought?

Agreed. I removed the truncated-file test.

It might be matter of taste, but how about moving printf() after the
`if (opt->quiet)`? The code might be clearer.

I moved the limit-block printf() after the quiet check.

Also, this fix should be backpatched to v17, where pg_walsummary was
introduced?

Agreed. I tested the updated patch against REL_17_STABLE and
REL_18_STABLE, and the pg_walsummary test suite passes on both.
The patch applies cleanly to REL_18_STABLE. On REL_17_STABLE, the
code change applies cleanly, but the test needs a small context
adjustment because that branch does not contain the pg_stat_io check.

Regards,

Koshi Shibagaki
FUJITSU LIMITED
https://www.fujitsu.com/

Attachments:

t254056_4
v2-0001-pg_walsummary-quiet.patchapplication/octet-stream; name=v2-0001-pg_walsummary-quiet.patchDownload+22-6
#5Fujii Masao
masao.fujii@gmail.com
In reply to: Koshi Shibagaki (Fujitsu) (#4)
Re: [PATCH] pg_walsummary: suppress limit output with --quiet

On Mon, Oct 5, 2026 at 5:46 PM Koshi Shibagaki (Fujitsu)
<shibagaki.koshi@fujitsu.com> wrote:

Agreed. I tested the updated patch against REL_17_STABLE and
REL_18_STABLE, and the pg_walsummary test suite passes on both.
The patch applies cleanly to REL_18_STABLE. On REL_17_STABLE, the
code change applies cleanly, but the test needs a small context
adjustment because that branch does not contain the pg_stat_io check.

Thanks for updating the patch! LGTM.

I've attached an updated version with some cosmetic changes and revised
commit log messages. I also created a patch for REL_17_STABLE.

Barring any objections, I will commit it.

Regards,

--
Fujii Masao

Attachments:

t254056_5
v3-0001-Fix-pg_walsummary-quiet-to-suppress-limit-block-o.patchapplication/octet-stream; name=v3-0001-Fix-pg_walsummary-quiet-to-suppress-limit-block-o.patchDownload+18-7
nocfbot-v3-0001-PG17-Fix-pg_walsummary-quiet-to-suppress-limit-block-o.patchapplication/octet-stream; name=nocfbot-v3-0001-PG17-Fix-pg_walsummary-quiet-to-suppress-limit-block-o.patchDownload+18-7
#6Koshi Shibagaki (Fujitsu)
shibagaki.koshi@fujitsu.com
In reply to: Fujii Masao (#5)
Re: [PATCH] pg_walsummary: suppress limit output with --quiet

Fujii-san,

Thanks for updating the patch and revising the commit log messages.
LGTM. No objections from me.

Regards,

Koshi Shibagaki
FUJITSU LIMITED
https://www.fujitsu.com/

#7Hayato Kuroda (Fujitsu)
kuroda.hayato@fujitsu.com
In reply to: Fujii Masao (#5)
RE: [PATCH] pg_walsummary: suppress limit output with --quiet

Dear Fujii-san,

Thanks for updating the patch! LGTM.

I've attached an updated version with some cosmetic changes and revised
commit log messages. I also created a patch for REL_17_STABLE.

Thanks for updating the patch. One minor point: command_like() might be
better in below if we assume the command returns 0 and no stderr. But
not a strong opinion.

```
+command_checks_all([ 'pg_walsummary', '-q', @summaries ],
+	0, [qr/\A\z/], [qr/\A\z/], "-q suppresses all output");
```

Best regards,
Hayato Kuroda
FUJITSU LIMITED

#8Fujii Masao
masao.fujii@gmail.com
In reply to: Hayato Kuroda (Fujitsu) (#7)
Re: [PATCH] pg_walsummary: suppress limit output with --quiet

On Wed, Oct 7, 2026 at 10:56 AM Hayato Kuroda (Fujitsu)
<kuroda.hayato@fujitsu.com> wrote:

Thanks for updating the patch. One minor point: command_like() might be
better in below if we assume the command returns 0 and no stderr. But
not a strong opinion.

```
+command_checks_all([ 'pg_walsummary', '-q', @summaries ],
+       0, [qr/\A\z/], [qr/\A\z/], "-q suppresses all output");
```

Okay, I've replaced it with command_like(). How about the attached updated
patches?

Regards,

--
Fujii Masao

Attachments:

t254056_8
nocfbot-v4-0001-PG17-Fix-pg_walsummary-quiet-to-suppress-limit-block-o.patchapplication/octet-stream; name=nocfbot-v4-0001-PG17-Fix-pg_walsummary-quiet-to-suppress-limit-block-o.patchDownload+18-7
v4-0001-Fix-pg_walsummary-quiet-to-suppress-limit-block-o.patchapplication/octet-stream; name=v4-0001-Fix-pg_walsummary-quiet-to-suppress-limit-block-o.patchDownload+18-7
#9Hayato Kuroda (Fujitsu)
kuroda.hayato@fujitsu.com
In reply to: Fujii Masao (#8)
RE: [PATCH] pg_walsummary: suppress limit output with --quiet

Dear Fujii-san,

Okay, I've replaced it with command_like(). How about the attached updated
patches?

Yes, it's same as my expectation. LGTM.

Best regards,
Hayato Kuroda
FUJITSU LIMITED

#10Fujii Masao
masao.fujii@gmail.com
In reply to: Hayato Kuroda (Fujitsu) (#9)
Re: [PATCH] pg_walsummary: suppress limit output with --quiet

On Wed, Oct 7, 2026 at 11:40 AM Hayato Kuroda (Fujitsu)
<kuroda.hayato@fujitsu.com> wrote:

Yes, it's same as my expectation. LGTM.

I've pushed the patch. Thanks!

Regards,

--
Fujii Masao