puppetlabs-postgresql icon indicating copy to clipboard operation
puppetlabs-postgresql copied to clipboard

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

Open evgeni opened this issue 1 year ago • 2 comments

Fixes: #1576

Summary

see subject and linked issue

Additional Context

Add any additional context about the problem here.

  • [ ] Root cause and the steps to reproduce. (If applicable)
  • [ ] Thought process behind the implementation.

Related Issues (if any)

#1576

Checklist

  • [ ] 🟢 Spec tests.
  • [ ] 🟢 Acceptance tests.
  • [ ] Manually verified. (For example puppet apply)

evgeni avatar Feb 21 '24 14:02 evgeni

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}

ekohl avatar Feb 21 '24 14:02 ekohl

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"

evgeni avatar Feb 21 '24 14:02 evgeni