public inbox for [email protected]help / color / mirror / Atom feed
Documentation/Behavior: Systemd Type=notify failure with pg_ctl on Debian 12 3+ messages / 3 participants [nested] [flat]
* Documentation/Behavior: Systemd Type=notify failure with pg_ctl on Debian 12 @ 2026-01-08 16:54 PG Doc comments form <[email protected]> 2026-02-25 01:10 ` Re: Documentation/Behavior: Systemd Type=notify failure with pg_ctl on Debian 12 David G. Johnston <[email protected]> 2026-02-25 18:23 ` Re: Documentation/Behavior: Systemd Type=notify failure with pg_ctl on Debian 12 Greg Sabino Mullane <[email protected]> 0 siblings, 2 replies; 3+ messages in thread From: PG Doc comments form @ 2026-01-08 16:54 UTC (permalink / raw) To: [email protected]; +Cc: [email protected] The following documentation comment has been logged on the website: Page: https://www.postgresql.org/docs/18/server-start.html Description: **PostgreSQL Version:** 18.1 (devel/snapshot) and 17.5 **Operating System:** Debian 12.11 (amd64) **Installation Method:** Source compilation **Configure Options:** `./configure --prefix=/usr/local/services/pgsql-18.1 --with-llvm --with-systemd` **Description:** I am encountering an issue starting the PostgreSQL service using systemd after compiling from source with `--with-systemd`. While the server starts correctly when invoking `pg_ctl` manually from the command line, it fails to start when using a systemd unit file configured with `Type=notify`, which references the documentation at [https://www.postgresql.org/docs/current/server-start.html](https://www.postgresql.org/docs/current/server-start.html). **Steps to Reproduce:** 1. Compile and install PostgreSQL with systemd support. 2. Create a systemd unit file as follows (using `pg_ctl` in ExecStart): ```Ini [Unit] Description=PostgreSQL database server Documentation=man:postgres(1) After=network-online.target Wants=network-online.target [Service] Type=notify User=postgres WorkingDirectory=/usr/local/services/pgsql-18.1 # Using pg_ctl to start the service ExecStart=/usr/local/services/pgsql-18.1/bin/pg_ctl start -D /usr/local/services/pgsql-18.1/data -l /usr/local/services/pgsql-18.1/pg.log ExecReload=/bin/kill -HUP $MAINPID KillMode=mixed KillSignal=SIGINT TimeoutSec=infinity [Install] WantedBy=multi-user.target ``` 3. Run `sudo systemctl daemon-reload` and `sudo systemctl start postgresql`. **Observed Result:** The service hangs in the "activating" state until it times out, even though the database process is actually running in the background. Systemd eventually kills the process because it never receives the readiness notification. `pg.log` (even at debug5 level) shows no errors, confirming the database started but the notification was not acknowledged by systemd. **Analysis & Fix:** Since `ExecStart` executes `pg_ctl`, but the `sd_notify` signal is sent by the forked `postgres` process, systemd ignores the signal by default. I found that adding the following lines to the `[Service]` section fixes the issue entirely: ```Ini NotifyAccess=all PIDFile=/usr/local/services/pgsql-18.1/data/postmaster.pid ``` **Suggestion:** The documentation regarding Systemd integration (specifically when using `pg_ctl` combined with `Type=notify`) might be incomplete. It appears that `NotifyAccess=all` is mandatory when `ExecStart` is a wrapper (like `pg_ctl`) rather than the `postgres` binary itself. I confirmed this behavior on both PostgreSQL v18.1 and v17.5 on Debian 12. I suggest updating the documentation examples or adding a note about `NotifyAccess` for users compiling with `--with-systemd`. Best regards. ^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Documentation/Behavior: Systemd Type=notify failure with pg_ctl on Debian 12 2026-01-08 16:54 Documentation/Behavior: Systemd Type=notify failure with pg_ctl on Debian 12 PG Doc comments form <[email protected]> @ 2026-02-25 01:10 ` David G. Johnston <[email protected]> 1 sibling, 0 replies; 3+ messages in thread From: David G. Johnston @ 2026-02-25 01:10 UTC (permalink / raw) To: [email protected]; [email protected] These forms submit plain text - submitting markdown makes them more difficult to review. In particular the link format doesn't play well with my mail reader's link auto-detection. On Fri, Jan 9, 2026 at 1:10 AM PG Doc comments form <[email protected]> wrote: > The documentation regarding Systemd integration (specifically when using > `pg_ctl` combined with `Type=notify`) might be incomplete. > Such documentation is nonexistent, not incomplete. The provided unit file for systemd doesn't use pg_ctl, I suppose presumably for this or a similar reason. It uses the postgres binary directly. Such, I'm not seeing a bug here (I suppose a comment pointing out that/why pg_ctl is not used might be in order). I'm not opposed to possibly adding more detail or alternatives to this part of the documentation - though the number of people doing their own unit files is few compared to those using ones bundled in a package - but the lack or responders seems to suggest such effort is not high on anyone's list. David J. ^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Documentation/Behavior: Systemd Type=notify failure with pg_ctl on Debian 12 2026-01-08 16:54 Documentation/Behavior: Systemd Type=notify failure with pg_ctl on Debian 12 PG Doc comments form <[email protected]> @ 2026-02-25 18:23 ` Greg Sabino Mullane <[email protected]> 1 sibling, 0 replies; 3+ messages in thread From: Greg Sabino Mullane @ 2026-02-25 18:23 UTC (permalink / raw) To: [email protected]; [email protected] The only possible doc change I think warranted is to tell people NOT to use pg_ctl with systemd (because it makes no sense), but just use the binary instead. However, the example in the docs ( https://www.postgresql.org/docs/current/server-start.html) already does that, ,and works fine as written, so I don't think the docs should anticipate every way in which someone might wrongly modify the file. Cheers, Greg -- Crunchy Data - https://www.crunchydata.com Enterprise Postgres Software Products & Tech Support ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-02-25 18:23 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-01-08 16:54 Documentation/Behavior: Systemd Type=notify failure with pg_ctl on Debian 12 PG Doc comments form <[email protected]> 2026-02-25 01:10 ` David G. Johnston <[email protected]> 2026-02-25 18:23 ` Greg Sabino Mullane <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox