Re: pg_rewind problem: cannot find WAL

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Luca Ferrari <fluca1978(at)gmail(dot)com>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_rewind problem: cannot find WAL
Date: 2025-05-08 15:10:51
Message-ID: 696cacde-79d0-4897-93bc-68fa317a7eb4@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 5/8/25 04:26, Luca Ferrari wrote:
> On Thu, May 8, 2025 at 8:54 AM Luca Ferrari <fluca1978(at)gmail(dot)com> wrote:
>>
>> I've pgbackrest making backups, so I have an archive_command. I'm
>> going to see if putting a restore_command can fix the problem.
>>
>
> But I'm facing a quite trivial problem: in ubuntu installation the
> configuration files are separated from the PGDATA.
> Apparently pg_rewind is trying to read postgresql.conf to get the
> restore_command, and I don't know how to specify the different
> location of the postgresql.conf (cannot specifcy -c as in postgres):
>
> $ /usr/lib/postgresql/17/bin/pg_rewind -D /var/lib/postgresql/17/main
> --source-server="user=replica_fluca host=dev-psqlha3
> dbname=replica_fluca" -R -P --debug -c
> postgres: could not access the server configuration file
> "/var/lib/postgresql/17/main/postgresql.conf": No such file or
> directory
> no data was returned by command "/usr/lib/postgresql/17/bin/postgres
> -D /var/lib/postgresql/17/main -C restore_command"
> child process exited with exit code 2
> pg_rewind: error: could not read restore_command from target cluster
>
> Any idea?

/usr/lib/postgresql/17/bin/pg_rewind --help
pg_rewind resynchronizes a PostgreSQL cluster with another copy of the
cluster.

Usage:
pg_rewind [OPTION]...

Options:
-c, --restore-target-wal use "restore_command" in target
configuration to
retrieve WAL files from archives
-D, --target-pgdata=DIRECTORY existing data directory to modify
--source-pgdata=DIRECTORY source data directory to synchronize with
--source-server=CONNSTR source server to synchronize with
-n, --dry-run stop before modifying anything
-N, --no-sync do not wait for changes to be written
safely to disk
-P, --progress write progress messages
-R, --write-recovery-conf write configuration for replication
(requires --source-server)
--config-file=FILENAME use specified main server configuration
file when running target cluster
--debug write a lot of debug messages
--no-ensure-shutdown do not automatically fix unclean shutdown
--sync-method=METHOD set method for syncing files to disk
-V, --version output version information, then exit
-?, --help show this help, then exit

So use --config-file=FILENAME?

> Clearly, postgresql.auto.conf is within PGDATA, and since my
> recovery_command is there, one trick could be to touch and empty
> PGDATA/postgresql.conf, pg_rewind, remove the fake configurtion file.
> But I'm sure there is a smarter solution.
>
> Thanks,
> Luca
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ertan Küçükoglu 2025-05-08 16:29:30 EDB Download for PostgreSQL 17.5 is broken
Previous Message Luca Ferrari 2025-05-08 14:43:45 Re: pg_rewind problem: cannot find WAL