From: Michael Paquier <michael.paquier@gmail.com>
To: pgsql-bugs@postgresql.org
Subject: contrib/start-scripts/linux failing on RHEL 6 with ~9.3 because of missing oom_score_adj
Date: Wed, 22 Apr 2015 09:56:48 +0900
Message-ID: <CAB7nPqQcCSBDAWO45hH0FWDcHi_HcxHmyMLukiMzaDcd0W06sA@mail.gmail.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Hi all,
Support for oom_score_adj has been added in kernel 2.6.36, a version
newer than 2.6.32-71 which is embedded in RHEL6, so the startup script
contrib/start-scripts/linux would fail because it does not check for
the presence of oom_score_adj before adding the value of OOM_SCORE_ADJ
to it.
We could argue that this is not directly a problem of PG itself as one
could just copy the startup script from the code tree to create its
own service script and fix it, still I am getting the feeling that we
should show a better logic with something like the patch attached.
Thoughts?
--
Michael
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugsAttachments:20150422_startup_oom_fix.patch (text/x-diff, 1.6K) downloaddiff --git a/contrib/start-scripts/linux b/contrib/start-scripts/linuxindex b950cf5..95a18e0 100644--- a/contrib/start-scripts/linux+++ b/contrib/start-scripts/linux@@ -65,6 +65,10 @@ DAEMON="$prefix/bin/postmaster"
# What to use to shut down the postmaster
PGCTL="$prefix/bin/pg_ctl"
+# OOM killer control files+PG_FILE_OOM_SCORE_ADJ="/proc/self/oom_score_adj"+PG_FILE_OOM_ADJ="/proc/self/oom_adj"+
set -e
# Only start if we can find the postmaster.
@@ -82,8 +86,12 @@ test -x $DAEMON ||
case $1 in
start)
echo -n "Starting PostgreSQL: "
- test x"$OOM_SCORE_ADJ" != x && echo "$OOM_SCORE_ADJ" > /proc/self/oom_score_adj- test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj+ test -e "$PG_FILE_OOM_SCORE_ADJ" && \+ test x"$OOM_SCORE_ADJ" != x && \+ echo "$OOM_SCORE_ADJ" > $PG_FILE_OOM_SCORE_ADJ+ test -e "$PG_FILE_OOM_ADJ" && \+ test x"$OOM_ADJ" != x && \+ echo "$OOM_ADJ" > $PG_FILE_OOM_ADJ
su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
echo "ok"
;;
@@ -95,8 +103,12 @@ case $1 in
restart)
echo -n "Restarting PostgreSQL: "
su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"
- test x"$OOM_SCORE_ADJ" != x && echo "$OOM_SCORE_ADJ" > /proc/self/oom_score_adj- test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj+ test -e "$PG_FILE_OOM_SCORE_ADJ" && \+ test x"$OOM_SCORE_ADJ" != x && \+ echo "$OOM_SCORE_ADJ" > $PG_FILE_OOM_SCORE_ADJ+ test -e "$PG_FILE_OOM_ADJ" && \+ test x"$OOM_ADJ" != x && \+ echo "$OOM_ADJ" > $PG_FILE_OOM_ADJ
su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
echo "ok"
;;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: michael.paquier@gmail.com
Subject: Re: contrib/start-scripts/linux failing on RHEL 6 with ~9.3 because of missing oom_score_adj
In-Reply-To: <CAB7nPqQcCSBDAWO45hH0FWDcHi_HcxHmyMLukiMzaDcd0W06sA@mail.gmail.com>
References: <CAB7nPqQcCSBDAWO45hH0FWDcHi_HcxHmyMLukiMzaDcd0W06sA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox