puppetlabs / puppetlabs-postgresql

Puppet module for managing PostgreSQL
Apache License 2.0
228 stars 614 forks source link

don't set data_directory in config when we configure it via env #1577

Open evgeni opened 8 months ago

evgeni commented 8 months ago

Fixes: #1576

Summary

see subject and linked issue

Additional Context

Add any additional context about the problem here.

Related Issues (if any)

1576

Checklist

ekohl commented 8 months ago

I'm not sure the systemd check is relevant. Debian also starts it via systemd, but somehow does read data_directory via postgresql.conf.

Debian uses /usr/bin/pg_ctlcluster to start, which is a perl script. That sets -D $info{'pgdata'}. My perl isn't great, but I think it reads postgresql.conf to get the value.

The official postgresql.org packages on Red Hat match what the distro packages do:

Environment=PGDATA=/var/lib/pgsql/13/data/
ExecStart=/usr/pgsql-13/bin/postmaster -D ${PGDATA}
evgeni commented 8 months ago

I'm not sure the systemd check is relevant. Debian also starts it via systemd, but somehow does read data_directory via postgresql.conf.

Well, this is where we set PGDATA explicitly. So it was a safe start.

Debian uses /usr/bin/pg_ctlcluster to start, which is a perl script. That sets -D $info{'pgdata'}. My perl isn't great, but I think it reads postgresql.conf to get the value.

-D really means "find postgresql.conf in that directory and run with it", which can point at a data_directory somewhere completely different (see https://www.postgresql.org/message-id/3566642.1618422939%40sss.pgh.pa.us)

The official postgresql.org packages on Red Hat match what the distro packages do:

Environment=PGDATA=/var/lib/pgsql/13/data/
ExecStart=/usr/pgsql-13/bin/postmaster -D ${PGDATA}

"good"