diff options
| author | Michael Paquier | 2020-04-01 01:57:03 +0000 |
|---|---|---|
| committer | Michael Paquier | 2020-04-01 01:57:03 +0000 |
| commit | a7e8ece41cf7a96d8a9c4c037cdfef304d950831 (patch) | |
| tree | 4d41665ee21d8ac941dad650bd8a757a0546a7a1 /src/include | |
| parent | 92d31085e926253aa650b9d1e1f2f09934d0ddfc (diff) | |
Add -c/--restore-target-wal to pg_rewind
pg_rewind needs to copy from the source cluster to the target cluster a
set of relation blocks changed from the previous checkpoint where WAL
forked up to the end of WAL on the target. Building this list of
relation blocks requires a range of WAL segments that may not be present
anymore on the target's pg_wal, causing pg_rewind to fail. It is
possible to work around this issue by copying manually the WAL segments
needed but this may lead to some extra and actually useless work.
This commit introduces a new option allowing pg_rewind to use a
restore_command while doing the rewind by grabbing the parameter value
of restore_command from the target cluster configuration. This allows
the rewind operation to be more reliable, so as only the WAL segments
needed by the rewind are restored from the archives.
In order to be able to do that, a new routine is added to src/common/ to
allow frontend tools to restore files from archives using an
already-built restore command. This version is more simple than the
backend equivalent as there is no need to handle the non-recovery case.
Author: Alexey Kondratov
Reviewed-by: Andrey Borodin, Andres Freund, Alvaro Herrera, Alexander
Korotkov, Michael Paquier
Discussion: https://postgr.es/m/a3acff50-5a0d-9a2c-b3b2-ee36168955c1@postgrespro.ru
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/common/fe_archive.h | 21 | ||||
| -rw-r--r-- | src/include/port.h | 3 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/include/common/fe_archive.h b/src/include/common/fe_archive.h new file mode 100644 index 00000000000..495b560d245 --- /dev/null +++ b/src/include/common/fe_archive.h @@ -0,0 +1,21 @@ +/*------------------------------------------------------------------------- + * + * fe_archive.h + * Routines to access WAL archives from frontend + * + * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/common/fe_archive.h + * + *------------------------------------------------------------------------- + */ +#ifndef FE_ARCHIVE_H +#define FE_ARCHIVE_H + +extern int RestoreArchivedFile(const char *path, + const char *xlogfname, + off_t expectedSize, + const char *restoreCommand); + +#endif /* FE_ARCHIVE_H */ diff --git a/src/include/port.h b/src/include/port.h index 29f3e39e5b3..20a5de1b7a7 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -102,10 +102,11 @@ extern void pgfnames_cleanup(char **filenames); /* Portable locale initialization (in exec.c) */ extern void set_pglocale_pgservice(const char *argv0, const char *app); -/* Portable way to find binaries (in exec.c) */ +/* Portable way to find and execute binaries (in exec.c) */ extern int find_my_exec(const char *argv0, char *retpath); extern int find_other_exec(const char *argv0, const char *target, const char *versionstr, char *retpath); +extern char *pipe_read_line(char *cmd, char *line, int maxsize); /* Doesn't belong here, but this is used with find_other_exec(), so... */ #define PG_BACKEND_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n" |
