Hi. If an system is going down to ram postgresql is often an good candidate to be killed by oom-killer. Posgresql documentation (https://www.postgresql.org/docs/11/kernel-resources.html#LINUX-MEMORY-OVERCOMMIT) provide some tricks to prevents that postmaster process will be killed, making the database inconsistent and taking a long time to starting up. In gentoo linux startup file (openrc) there aren't a point to adjust oom_score_adj for postmaster but is possible set PG_OOM_ADJUST_FILE and PG_OOM_ADJUST_VALUE in PG_EXTRA_ENV for correcting child process in /etc/conf.d/postgres-X. An idea must be create a new variable in /etc/conf.d/postgres-X (eg. PG_MASTER_OOM_ADJUST="-1000") and using it in init scrpit: if [ ${PG_MASTER_OOM_ADJUST} ] ; then echo ${PG_MASTER_OOM_ADJUST} > /proc/self/oom_score_adj fi before process start, complete patch will be attached. Many thanks Reproducible: Always
Created attachment 599060 [details, diff] patch to init script this patch require var PG_MASTER_OOM_ADJUST will be setting in /etc/conf.d/postgres-X
Comment on attachment 599060 [details, diff] patch to init script >--- postgresql-11-20191210 2019-12-10 16:53:39.000000000 +0100 >+++ postgresql-11 2019-12-10 17:40:02.000000000 +0100 >@@ -86,6 +86,9 @@ > > rm -f "${DATA_DIR%/}/postmaster.pid" > >+ if [ ${PG_MASTER_OOM_ADJUST} ] ; then >+ echo ${PG_MASTER_OOM_ADJUST} > /proc/self/oom_score_adj That doesn't prevent the process getting killed; it would merely decrease the likelihood of killing it in favour of killing other processes first.
(In reply to Jeroen Roovers from comment #2) > Comment on attachment 599060 [details, diff] [details, diff] > patch to init script > > >--- postgresql-11-20191210 2019-12-10 16:53:39.000000000 +0100 > >+++ postgresql-11 2019-12-10 17:40:02.000000000 +0100 > >@@ -86,6 +86,9 @@ > > > > rm -f "${DATA_DIR%/}/postmaster.pid" > > > >+ if [ ${PG_MASTER_OOM_ADJUST} ] ; then > >+ echo ${PG_MASTER_OOM_ADJUST} > /proc/self/oom_score_adj > > That doesn't prevent the process getting killed; it would merely decrease > the likelihood of killing it in favour of killing other processes first. Of courese, I've used an incorrect term.