Re: [Patch] pg_rewind: options to use restore_command fromrecovery.conf or command line - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: [Patch] pg_rewind: options to use restore_command fromrecovery.conf or command line
Date
Msg-id 20200228064357.GB2688@paquier.xyz
Whole thread Raw
In response to Re: [Patch] pg_rewind: options to use restore_command fromrecovery.conf or command line  (Alexey Kondratov <a.kondratov@postgrespro.ru>)
Responses Re: [Patch] pg_rewind: options to use restore_command fromrecovery.conf or command line
List pgsql-hackers
On Thu, Feb 27, 2020 at 06:29:34PM +0300, Alexey Kondratov wrote:
> On 2020-02-27 16:41, Alexey Kondratov wrote:
> >
> > New version of the patch is attached. Thanks again for your review.
> >
>
> Last patch (v18) got a conflict with one of today commits (05d8449e73).
> Rebased version is attached.

The shape of the patch is getting better.  I have found some issues
when reading through the patch, but nothing huge.

+   printf(_("  -c, --restore-target-wal       use restore_command in target config\n"));
+   printf(_("                                 to retrieve WAL files from archive\n"));
[...]
        {"progress", no_argument, NULL, 'P'},
+       {"restore-target-wal", no_argument, NULL, 'c'},
It may be better to reorder that alphabetically.

+   if (rc != 0)
+       /* Sanity check, should never happen. */
+       elog(ERROR, "failed to build restore_command due to missing parameters");
No point in having this comment IMO.

+/* logging support */
+#define pg_fatal(...) do { pg_log_fatal(__VA_ARGS__); exit(1); } while(0)
Actually, I don't think that this is a good idea to name this
pg_fatal() as we have the same think in pg_rewind so it could be
confusing.

-   while ((c = getopt_long(argc, argv, "D:nNPR", long_options,
    &option_index)) != -1)
+   while ((c = getopt_long(argc, argv, "D:nNPRc", long_options,
    &option_index)) != -1)
Alphabetical order here.

+       rmdir($node_master->archive_dir);
rmtree() is used in all our other tests.

+               pg_log_error("archive file \"%s\" has wrong size: %lu instead of %lu, %s",
+                            xlogfname, (unsigned long) stat_buf.st_size,
+                            (unsigned long) expectedSize, strerror(errno));
I think that the error message should be reworded: "unexpected WAL
file size for \"%s\": %lu instead of %lu".  Please note that there is
no need for strerror() here at all, as errno should be 0.

+    if (xlogfd < 0)
+        pg_log_error("could not open file \"%s\" restored from archive: %s\n",
+                     xlogpath, strerror(errno));
[...]
+    pg_log_error("could not stat file \"%s\" restored from archive: %s",
+                        xlogpath, strerror(errno));
No need for strerror() as you can just use %m.  And no need for the
extra newline at the end as pg_log_* routines do that by themselves.

+   pg_log_error("could not restore file \"%s\" from archive\n",
+                xlogfname);
No need for a newline here.

--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Richard Guo
Date:
Subject: Trying to pull up EXPR SubLinks
Next
From: Kyotaro Horiguchi
Date:
Subject: Make mesage at end-of-recovery less scary.