Hi,

On Wed, Jan 29, 2025 at 07:01:00PM +0000, Ben Harris wrote:
> On Wed, 29 Jan 2025, Ben Harris wrote

I tried to reproduce the reinit failure, but it always worked for me.
Not sure what is different on your side :-/

> > If I add "WorkingDirectory=~" to patroni@.service, even on a current
> > Patroni package, reinit starts working again.  This gives me a
> > convenient workaround, but I'll try to work out the cause as well.
> 
> And after a bit of fighting with strace, I've spotted where the bug (or
> rather the anti-bug) is.  Here, in pg_clonecluster_patroni:
> 
>     rm -f etc/postgresql/$VERSION/$CLUSTER/postgresql.base.conf
> 
> Note the lack of a '/' before "etc".

Ouch, thanks for spotting that.
 
> This means that if the script is run with its current directory being / (as
> systemd runs services by default), then in will successfully delete
> postgresql.base.conf, pg_dropcluster will fail, and so reinit will fail. But
> if the current directory is set by systemd then the "rm" will fail,
> pg_dropcluster will succeed, and so reinit will succeed.
> 
> I would suggest that the proper fix here is to insert the missing '/' and
> move the "rm" command back to being after the "pg_dropcluster" command. Or
> just drop the "rm" command entirely.

I did the former now in the salsa git repo, however, that will only be
part of the 4.0.x releases.


Michael

Reply via email to