Re: [Patch] pg_rewind: options to use restore_command from recovery.conf or command line
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Alexey Kondratov <a.kondratov@postgrespro.ru>
Cc: Alexander Korotkov <a.korotkov@postgrespro.ru>, Alvaro Herrera <alvherre@2ndquadrant.com>, Liudmila Mantrova <l.mantrova@postgrespro.ru>, Thomas Munro <thomas.munro@gmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>, David Steele <david@pgmasters.net>, Andres Freund <andres@anarazel.de>, PostgreSQL-development <pgsql-hackers@postgresql.org>, Dmitry Dolgov <9erthalion6@gmail.com>, vladimirlesk@yandex-team.ru, dsarafan@yandex-team.ru
Date: 2020-02-28T06:43:57Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Move frontend-side archive APIs from src/common/ to src/fe_utils/
- 8d8b89266ca0 13.0 landed
- a3b2bf1fe7ce 14.0 landed
-
Add -c/--restore-target-wal to pg_rewind
- a7e8ece41cf7 13.0 landed
-
Move routine definitions of xlogarchive.c to a new header file
- 616ae3d2b056 13.0 landed
-
Move routine building restore_command to src/common/
- e09ad07b21a2 13.0 landed
-
Integrate recovery.conf into postgresql.conf
- 2dedf4d9a899 12.0 cited
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