Bug 272502 - databases/postgresql13-server: startup script not redirecting stdout, breaking Ansible
Summary: databases/postgresql13-server: startup script not redirecting stdout, breakin...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: pgsql
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-14 13:52 UTC by topical
Modified: 2025-02-21 21:24 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (pgsql)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description topical 2023-07-14 13:52:32 UTC
The startup script uses pg_ctl which forwards stdout from postgresql daemon to parent process.

Since py39-ansible-core-2.15, the "service" module waits until stdout of startup script is completely read. In our case, this will happen when the postgresql daemon terminates, i.e. never and so the Ansible playbook is stuck.

According to pg_ctl, this is a feature. But in real life, the only messages you get are

```
LOG:  ending log output to stderr
HINT:  Future log output will go to log destination "syslog".
```

So this feature is useless and makes trouble.

Either, pg_ctl must be fixed (which imho is unlikely as under Linux, usually systemd is used which has no problem with that behaviour) or we must modify the rc.d script to redirect stdout to /dev/null on startup.
Comment 1 Mina Galić freebsd_triage 2023-07-14 15:39:20 UTC
pg_ctl has a -l option
Comment 2 topical 2023-07-14 23:14:05 UTC
This option sends log to file, see man page:

-l filename
Append the server log output to filename. If the file does not exist, it is created. The umask is set to 077, so access to the log file from other users is disallowed by default.


This doesn‘t make much sense, since there is no useful logging output, only 

LOG:  ending log output to stderr 
HINT:  Future log output will go to log destination "syslog".

I don‘t want to create a new log file for these 2 (useless) messages only.
Comment 3 Palle Girgensohn freebsd_committer freebsd_triage 2023-07-17 16:40:06 UTC
I think that the best way is to remove the syslog configuration and use normal logging instead. The PostgreSQL community actually advices not to use syslog since it requires a syscall, which is considered an unnecessary overhead.

I haven't looked into how that would best be configured. Do you have any suggestions?

Otherwise, would a quick fix be to add `-l /dev/null` or just redirect stdout and stderr to /dev/null?
Comment 4 topical 2023-07-17 19:19:42 UTC
It seems that PostgreSQL prefers to do its own log management including rotation. All that can be configured in postgresql.conf. I would need to dig deeper to find a "perfect" configuration.

For the time being, just adding "-l /dev/null" seems to be sufficient.
Comment 5 commit-hook freebsd_committer freebsd_triage 2025-02-20 14:46:10 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e30c0647036e097b38ed2e56536333f95957f189

commit e30c0647036e097b38ed2e56536333f95957f189
Author:     Palle Girgensohn <girgen@FreeBSD.org>
AuthorDate: 2025-02-20 13:30:32 +0000
Commit:     Palle Girgensohn <girgen@FreeBSD.org>
CommitDate: 2025-02-20 14:41:24 +0000

    databases/postgresql??-*: Upgrade to latest versions

    The PostgreSQL Global Development Group has released an update to all
    supported versions of PostgreSQL, including 17.4, 16.8, 15.12, 14.17,
    and 13.20.

    The issues listed below affect PostgreSQL 17. Some of these issues may
    also affect other supported versions of PostgreSQL.

    Improve behavior of quoting functions in libpq. The fix for
    CVE-2025-1094 caused the quoting functions to not honor their string
    length parameters and, in some cases, cause crashes. This problem could
    be noticeable from a PostgreSQL client library, based on how it is
    integrated with libpq.

    Fix small memory leak in pg_createsubscriber.

    Also fix a problem in the FreeBSD port, where the rc script wouldn't
    return properly, messing up orchestration tools like ansible. [1]

    PR:             272502 [1]
    Release notes:  https://www.postgresql.org/docs/release/

 databases/postgresql13-server/Makefile            | 2 +-
 databases/postgresql13-server/distinfo            | 6 +++---
 databases/postgresql13-server/files/postgresql.in | 4 +++-
 databases/postgresql14-server/Makefile            | 2 +-
 databases/postgresql14-server/distinfo            | 6 +++---
 databases/postgresql14-server/files/postgresql.in | 4 +++-
 databases/postgresql15-server/Makefile            | 2 +-
 databases/postgresql15-server/distinfo            | 6 +++---
 databases/postgresql15-server/files/postgresql.in | 4 +++-
 databases/postgresql16-server/Makefile            | 2 +-
 databases/postgresql16-server/distinfo            | 6 +++---
 databases/postgresql16-server/files/postgresql.in | 4 +++-
 databases/postgresql17-server/Makefile            | 2 +-
 databases/postgresql17-server/distinfo            | 6 +++---
 databases/postgresql17-server/files/postgresql.in | 4 +++-
 15 files changed, 35 insertions(+), 25 deletions(-)
Comment 6 Palle Girgensohn freebsd_committer freebsd_triage 2025-02-20 15:14:06 UTC
I comitted a change adding -l /dev/null. Thanks!
Comment 7 commit-hook freebsd_committer freebsd_triage 2025-02-21 21:24:28 UTC
A commit in branch 2025Q1 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5bd503deb3eacaaa912fa16aa036bbd027bcbd2b

commit 5bd503deb3eacaaa912fa16aa036bbd027bcbd2b
Author:     Palle Girgensohn <girgen@FreeBSD.org>
AuthorDate: 2025-02-20 13:30:32 +0000
Commit:     Palle Girgensohn <girgen@FreeBSD.org>
CommitDate: 2025-02-21 21:22:15 +0000

    databases/postgresql??-*: Upgrade to latest versions

    The PostgreSQL Global Development Group has released an update to all
    supported versions of PostgreSQL, including 17.4, 16.8, 15.12, 14.17,
    and 13.20.

    The issues listed below affect PostgreSQL 17. Some of these issues may
    also affect other supported versions of PostgreSQL.

    Improve behavior of quoting functions in libpq. The fix for
    CVE-2025-1094 caused the quoting functions to not honor their string
    length parameters and, in some cases, cause crashes. This problem could
    be noticeable from a PostgreSQL client library, based on how it is
    integrated with libpq.

    Fix small memory leak in pg_createsubscriber.

    Also fix a problem in the FreeBSD port, where the rc script wouldn't
    return properly, messing up orchestration tools like ansible. [1]

    PR:             272502 [1]
    Release notes:  https://www.postgresql.org/docs/release/

    (cherry picked from commit e30c0647036e097b38ed2e56536333f95957f189)

 databases/postgresql13-server/Makefile            | 4 ++--
 databases/postgresql13-server/distinfo            | 6 +++---
 databases/postgresql13-server/files/postgresql.in | 4 +++-
 databases/postgresql14-server/Makefile            | 4 ++--
 databases/postgresql14-server/distinfo            | 6 +++---
 databases/postgresql14-server/files/postgresql.in | 4 +++-
 databases/postgresql15-server/Makefile            | 4 ++--
 databases/postgresql15-server/distinfo            | 6 +++---
 databases/postgresql15-server/files/postgresql.in | 4 +++-
 databases/postgresql16-server/Makefile            | 4 ++--
 databases/postgresql16-server/distinfo            | 6 +++---
 databases/postgresql16-server/files/postgresql.in | 4 +++-
 databases/postgresql17-server/Makefile            | 4 ++--
 databases/postgresql17-server/distinfo            | 6 +++---
 databases/postgresql17-server/files/postgresql.in | 4 +++-
 15 files changed, 40 insertions(+), 30 deletions(-)