Re: BUG #16982: pg_rewind cannot deal with configuration files (postgresql.conf) located outside data directory

From: Neil Chen <carpenter(dot)nail(dot)cz(at)gmail(dot)com>
To: edwin(dot)polkerman(at)splendiddata(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16982: pg_rewind cannot deal with configuration files (postgresql.conf) located outside data directory
Date: 2021-04-28 05:22:17
Message-ID: CAA3qoJmSxLfR69FEgVZhm3P_bFUxQSMKNUu38by_CJcwFo8O2g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Greetings,

On Wed, Apr 28, 2021 at 11:38 AM PG Bug reporting form <
noreply(at)postgresql(dot)org> wrote:

>
>
> In the used PostgreSQL setup the configuration files (postgresql.conf,
> pg_hha.conf and pg_ident.conf) are located in another location than the
> data
> directory: /etc/database/postgres/13/data
>
> In postgresql.conf following locations are updated:
>
> #------------------------------------------------------------------------------
> # FILE LOCATIONS
>
> #------------------------------------------------------------------------------
>
> # The default values of these variables are driven from the -D
> command-line
> # option or PGDATA environment variable, represented here as ConfigDir.
> data_directory = '/var/database/postgres/13/data'
> hba_file = '/etc/database/postgres/13/data/pg_hba.conf'
>
>
>
> ident_file = '/etc/database/postgres/13/data/pg_ident.conf'
>
> The cluster can be started with pg_ctl and use the path to postgresql.conf
> in -D:
> > pg_ctl -D /etc/database/postgres/13/data start
>
>
>
> Trying to use pg_rewind to synchronize a PostgreSQL data directory (e.g.
> bringing back failed master)
> > pg_rewind --target-pgdata=/etc/database/postgres/13/data -P -R -c
> --source-server='host=<ip-address source> port=5432 user=rewind_user
> password=rewind_user dbname=postgres'
>
> Observed result:
> ==========
> pg_rewind: connected to server
> pg_rewind: fatal: could not open file
> "/etc/database/postgres/13/data/global/pg_control" for reading: No such
> file
> or directory
>
> Improvement:
> It would be nice to have pg_rewind support postgresql.conf being located
> somewhere else than in the data directory, just like pg_ctl does.
>
> Of course it is possible to workaround the issue but it takes more steps
> than would be necessary (with increased error risk of copying and moving
> configuration files around).
>
> Not only applicable for PostgreSQL 13, but also for the other versions as
> well
>
>
Yes, I think in general, pg_rewind should also support this function. To
support it, you can copy the relevant code directly from pg_ctl, here is
the patch.
But of course, I hope to listen to other people's opinions, so that we can
understand why we didn't support this function before, and whether there
are any risks...

Thanks.
--
There is no royal road to learning.
HighGo Software Co.

Attachment Content-Type Size
0001-pg_rewind-patch.patch application/octet-stream 4.6 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message RekGRpth 2021-04-28 05:37:15 Re: BUG #16985: ModifyWaitEvent function does not have pgsocket fd and void *user_data arguments
Previous Message Tom Lane 2021-04-28 03:43:10 Re: BUG #16939: Plural interval for negative singular