Add progress reporting to pg_verifybackup

Lists: pgsql-hackers
From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Add progress reporting to pg_verifybackup
Date: 2023-01-06 07:28:42
Message-ID: CAD21AoC5+JOgMd4o3z_oxw0f8JDSsCYY7zSbhe-O9x7f33rw_A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi all,

I've attached the simple patch to add the progress reporting option to
pg_verifybackup. The progress information is displayed with --progress
option only during the checksum verification, which is the most time
consuming task. It cannot be used together with --quiet option.

Feedback is very welcome.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v1-0001-Add-progress-reporting-to-pg_verifybackup.patch application/octet-stream 7.7 KB

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add progress reporting to pg_verifybackup
Date: 2023-02-01 01:25:01
Message-ID: Y9m/[email protected]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Jan 06, 2023 at 04:28:42PM +0900, Masahiko Sawada wrote:
> I've attached the simple patch to add the progress reporting option to
> pg_verifybackup. The progress information is displayed with --progress
> option only during the checksum verification, which is the most time
> consuming task. It cannot be used together with --quiet option.

That looks helpful, particularly when a backup has many relation
files. Calculating the total size when browsing the file list looks
fine.

+ /* Complain if the specified arguments conflict */
+ if (show_progress && quiet)
+ pg_fatal("cannot specify both --progress and --quiet");

Nothing on HEAD proposes --progress and --quiet at the same time from
what I can see, so just disabling the combination is fine by me. For
the error message, I would recommend to switch to a more generic
pattern, as of:
"cannot specify both %s and %s", "-P/--progress", "-q/--quiet"

Could you add a check based on command_fails_like() in 004_options.pl,
at least? A second test to check after the output of --progress would
be a nice bonus, for example by sticking --progress into one of the
existing commands doing a command_like().
--
Michael


From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add progress reporting to pg_verifybackup
Date: 2023-02-02 05:57:44
Message-ID: CAD21AoCLBKAyjXyTJJ0GC2QtWtxXfFKDA7iyR=EqLqUp50iQYQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Feb 1, 2023 at 10:25 AM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Fri, Jan 06, 2023 at 04:28:42PM +0900, Masahiko Sawada wrote:
> > I've attached the simple patch to add the progress reporting option to
> > pg_verifybackup. The progress information is displayed with --progress
> > option only during the checksum verification, which is the most time
> > consuming task. It cannot be used together with --quiet option.
>
> That looks helpful, particularly when a backup has many relation
> files. Calculating the total size when browsing the file list looks
> fine.
>
> + /* Complain if the specified arguments conflict */
> + if (show_progress && quiet)
> + pg_fatal("cannot specify both --progress and --quiet");
>
> Nothing on HEAD proposes --progress and --quiet at the same time from
> what I can see, so just disabling the combination is fine by me. For
> the error message, I would recommend to switch to a more generic
> pattern, as of:
> "cannot specify both %s and %s", "-P/--progress", "-q/--quiet"

Agreed.

>
> Could you add a check based on command_fails_like() in 004_options.pl,
> at least?

Agreed, done in v2 patch.

> A second test to check after the output of --progress would
> be a nice bonus, for example by sticking --progress into one of the
> existing commands doing a command_like().

It seems that the --progress option doesn't work with command_like()
since the progress information is written in stderr but command_like()
doesn't want it.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v2-0001-Add-progress-reporting-to-pg_verifybackup.patch application/octet-stream 8.4 KB

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add progress reporting to pg_verifybackup
Date: 2023-02-02 06:12:16
Message-ID: [email protected]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Feb 02, 2023 at 02:57:44PM +0900, Masahiko Sawada wrote:
> It seems that the --progress option doesn't work with command_like()
> since the progress information is written in stderr but command_like()
> doesn't want it.

What about command_checks_all()? It should check for stderr, stdout
as well as the expected error code.
--
Michael


From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add progress reporting to pg_verifybackup
Date: 2023-02-02 08:56:47
Message-ID: CAD21AoD=+pmo4u3UryhTnWV+Pf8MDkWyVx6t6LMzPQUijXFZFQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Feb 2, 2023 at 3:12 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Thu, Feb 02, 2023 at 02:57:44PM +0900, Masahiko Sawada wrote:
> > It seems that the --progress option doesn't work with command_like()
> > since the progress information is written in stderr but command_like()
> > doesn't want it.
>
> What about command_checks_all()? It should check for stderr, stdout
> as well as the expected error code.

Seems a good idea. Please find an attached patch.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v3-0001-Add-progress-reporting-to-pg_verifybackup.patch application/octet-stream 9.1 KB

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add progress reporting to pg_verifybackup
Date: 2023-02-04 03:32:15
Message-ID: [email protected]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Feb 02, 2023 at 05:56:47PM +0900, Masahiko Sawada wrote:
> Seems a good idea. Please find an attached patch.

That seems rather OK seen from here. I'll see about getting that
applied except if there is an objection of any kind.
--
Michael


From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add progress reporting to pg_verifybackup
Date: 2023-02-06 00:35:16
Message-ID: [email protected]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Feb 04, 2023 at 12:32:15PM +0900, Michael Paquier wrote:
> That seems rather OK seen from here. I'll see about getting that
> applied except if there is an objection of any kind.

Okay, I have looked at that again this morning and I've spotted one
tiny issue: specifying --progress with --skip-checksums does not
really make sense.

Ignoring entries with a bad size would lead to incorrect progress
report (for example, say an entry in the manifest has a largely
oversized size number), so your approach on this side is correct. The
application of the ignore list via -i is also correct, as a patch
matching with should_ignore_relpath() does not compute an extra size
for total_size.

I was also wondering for a few minutes while on it whether it would
have been cleaner to move the check for should_ignore_relpath()
directly in verify_file_checksum() and verify_backup_file(), but
nobody has complained about that as being a problem, either.

What do you think about the updated version attached?
--
Michael

Attachment Content-Type Size
v4-0001-Add-progress-reporting-to-pg_verifybackup.patch text/x-diff 9.1 KB

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add progress reporting to pg_verifybackup
Date: 2023-02-06 03:27:51
Message-ID: CAD21AoCAk+XV9weyYkvxCKpVX6o2oEhr1qakjEXZrB-naOMYkQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Feb 6, 2023 at 9:35 AM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Sat, Feb 04, 2023 at 12:32:15PM +0900, Michael Paquier wrote:
> > That seems rather OK seen from here. I'll see about getting that
> > applied except if there is an objection of any kind.
>
> Okay, I have looked at that again this morning and I've spotted one
> tiny issue: specifying --progress with --skip-checksums does not
> really make sense.

I thought that too, but I thought it's better to ignore it, instead of
erroring out. For example, we can specify both --disable and
--progress options to pg_checksum commands, but we don't write any
progress information in this case.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com


From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add progress reporting to pg_verifybackup
Date: 2023-02-06 05:45:43
Message-ID: [email protected]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Feb 06, 2023 at 12:27:51PM +0900, Masahiko Sawada wrote:
> I thought that too, but I thought it's better to ignore it, instead of
> erroring out. For example, we can specify both --disable and
> --progress options to pg_checksum commands, but we don't write any
> progress information in this case.

Well, if you don't feel strongly about that, that's fine by me as
well, so I have applied your v3 with the tweaks I posted previously,
without the restriction on --skip-checksums.
--
Michael


From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add progress reporting to pg_verifybackup
Date: 2023-02-06 06:33:22
Message-ID: CAD21AoAK8ic=d02+HGoatO7wiVF28W6avvuFfg2KijggvCxwUQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Feb 6, 2023 at 2:45 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Mon, Feb 06, 2023 at 12:27:51PM +0900, Masahiko Sawada wrote:
> > I thought that too, but I thought it's better to ignore it, instead of
> > erroring out. For example, we can specify both --disable and
> > --progress options to pg_checksum commands, but we don't write any
> > progress information in this case.
>
> Well, if you don't feel strongly about that, that's fine by me as
> well, so I have applied your v3 with the tweaks I posted previously,
> without the restriction on --skip-checksums.

Thank you!

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com