Re: PSA: Systemd will kill PostgreSQL - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: PSA: Systemd will kill PostgreSQL
Date
Msg-id c1b3bc20-03ea-63b8-a079-7332d523ad2b@2ndquadrant.com
Whole thread Raw
In response to Re: PSA: Systemd will kill PostgreSQL  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: PSA: Systemd will kill PostgreSQL  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 8/16/16 11:24 AM, Tom Lane wrote:
> Not sure I believe that --- the cases that have been reported to us
> involved postgres processes that were still alive but had had their
> SysV semaphore sets deleted out from under them.  Likely the SysV
> shmem segments too, but that wouldn't cause any observable effects
> for the running cluster.  (It *would* risk breaking the interlock
> against starting a new postmaster, I fear.)
> 
> It might be that both behaviors exist now but more people know about
> how to turn off the killing-processes one.

They are two separate things.

Both are controlled by settings in logind.conf.

RemoveIPC=

controls whether System V IPC objects are removed when a user logs out.
System users are exempt.

This was turned on by default in systemd version 212 (2014-03-25).

RHEL7 ships 219.  Debian stable ships 215.

Apparently, the systemd package in RHEL7 is built with it defaulting to
off.  The package in Debian defaults to on, but I can't actually
reproduce the issue.

A brief look through the code and some reading between the lines of the
documentation shows that it only cleans up shared memory segments that
are no longer attached to, but there is no such check for semaphores.

So there are some issues here to be worked out.


KillUserProcesses=

controls whether all processes of a user should be killed when the user
logs out.  This was turned on by default in systemd version 230
(2016-05-21).  This is not yet shipped widely (Fedora Branched/25,
Debian testing, stable-backports).

There are various ways to adjust that, including the KillOnlyUsers=,
KillExcludeUsers=, loginctl enable-linger, systemd-run.  These are all
explained on the logind.conf man page.  (Being a "system user" has no
influence here.)

This will clearly result in some wide-spread annoyance among users and
some wide-spread rejoicing among system administrators, but other than
that I don't see a potential harm specific to PostgreSQL here.


-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [GENERAL] C++ port of Postgres
Next
From: Robert Haas
Date:
Subject: Re: Server crash due to SIGBUS(Bus Error) when trying to access the memory created using dsm_create().