Re: https://github.com/bnnanet/To-Dos/issues/43, bnnanet/serviceman#5
This happens when postgres is run
- with systemd
- as a system service
- as a user that can login
could not open shared memory segment "/PostgreSQL.2818577498": No such file or directory
For example, when adding postgres with serviceman, running as the app user.
Solutions vs Workarounds
- use
openrc (Alpine, Devuan) rather than systemd (Debian, CentOS)
- create a non-login
postgres user (TODO: document this)
Option 1: systemd fix
IMPORTANT: This does not work in practice, in my experience. systemd still wipes out the shared memory file periodically.
Disable systemd from clearing a user's /dev/shm during logind lifecycle events:
/etc/systemd/logind.conf:
sudo systemctl restart systemd-logind.service
Option 1: use a non login user
Create a user that does not have login access to run the postgres daemon.
Option 2: set postgres ipc to sysv or mmap
Switch postgres to use mmap (less efficient)
~/.local/share/postgres/var/postgresql.conf:
dynamic_shared_memory_type = mmap
Triggers
Login via ssh does trigger loginds lifecycle management.
sudo loginctl list-sessions