1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-31 22:04:40 +03:00

Add option --config-file to pg_rewind

This option is useful to do a rewind with the server configuration file
(aka postgresql.conf) located outside the data directory, which is
something that some Linux distributions and some HA tools like to rely
on.  As a result, this can simplify the logic around a rewind by
avoiding the copy of such files before running pg_rewind.

This option affects pg_rewind when it internally starts the target
cluster with some "postgres" commands, adding -c config_file=FILE to the
command strings generated, when:
- retrieving a restore_command using a "postgres -C" command for
-c/--restore-target-wal.
- forcing crash recovery once to get the cluster into a clean shutdown
state.

Author: Gunnar "Nick" Bluth
Reviewed-by: Michael Banck, Alexander Kukushkin, Michael Paquier,
Alexander Alekseev
Discussion: https://postgr.es/m/7c59265d-ac50-b0aa-ca1e-65e8bd27642a@pro-open.de
This commit is contained in:
Michael Paquier
2022-04-07 08:51:49 +09:00
parent a82a5eee31
commit 0d5c387573
3 changed files with 47 additions and 4 deletions

View File

@ -263,7 +263,9 @@ sub run_pg_rewind
"--debug",
"--source-pgdata=$standby_pgdata",
"--target-pgdata=$primary_pgdata",
"--no-sync"
"--no-sync",
"--config-file",
"$tmp_folder/primary-postgresql.conf.tmp"
],
'pg_rewind local');
}
@ -276,7 +278,8 @@ sub run_pg_rewind
'pg_rewind', "--debug",
"--source-server", $standby_connstr,
"--target-pgdata=$primary_pgdata", "--no-sync",
"--write-recovery-conf"
"--write-recovery-conf", "--config-file",
"$tmp_folder/primary-postgresql.conf.tmp"
],
'pg_rewind remote');
@ -323,7 +326,8 @@ sub run_pg_rewind
# Note the use of --no-ensure-shutdown here. WAL files are
# gone in this mode and the primary has been stopped
# gracefully already.
# gracefully already. --config-file reuses the original
# postgresql.conf as restore_command has been enabled above.
command_ok(
[
'pg_rewind',
@ -332,7 +336,9 @@ sub run_pg_rewind
"--target-pgdata=$primary_pgdata",
"--no-sync",
"--no-ensure-shutdown",
"--restore-target-wal"
"--restore-target-wal",
"--config-file",
"$primary_pgdata/postgresql.conf"
],
'pg_rewind archive');
}