On Wed, 29 Jan 2025, Ben Harris wrote
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".
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.
--
Ben Harris, University of Cambridge Information Services.