diff options
author | Tom Lane | 2010-01-11 18:39:32 +0000 |
---|---|---|
committer | Tom Lane | 2010-01-11 18:39:32 +0000 |
commit | d5e0029862be8729f2cb25736469ed71068424c5 (patch) | |
tree | d464e7360405e945cbd1f47d6e48d6f0d4199eb3 /contrib/start-scripts | |
parent | 292176a118da6979e5d368a4baf27f26896c99a5 (diff) |
Add some simple support and documentation for using process-specific oom_adj
settings to prevent the postmaster from being OOM-killed on Linux systems.
Alex Hunsaker and Tom Lane
Diffstat (limited to 'contrib/start-scripts')
-rw-r--r-- | contrib/start-scripts/linux | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/contrib/start-scripts/linux b/contrib/start-scripts/linux index 6d6ff2aed9..e1ea1e3da4 100644 --- a/contrib/start-scripts/linux +++ b/contrib/start-scripts/linux @@ -24,7 +24,7 @@ # Original author: Ryan Kirkpatrick <[email protected]> -# $PostgreSQL: pgsql/contrib/start-scripts/linux,v 1.9 2009/08/27 16:59:38 tgl Exp $ +# $PostgreSQL: pgsql/contrib/start-scripts/linux,v 1.10 2010/01/11 18:39:32 tgl Exp $ ## EDIT FROM HERE @@ -40,6 +40,14 @@ PGUSER=postgres # Where to keep a log file PGLOG="$PGDATA/serverlog" +# It's often a good idea to protect the postmaster from being killed by the +# OOM killer (which will tend to preferentially kill the postmaster because +# of the way it accounts for shared memory). Setting the OOM_ADJ value to +# -17 will disable OOM kill altogether. If you enable this, you probably want +# to compile PostgreSQL with "-DLINUX_OOM_ADJ=0", so that individual backends +# can still be killed by the OOM killer. +#OOM_ADJ=-17 + ## STOP EDITING HERE # The path that is to be used for the script @@ -62,6 +70,7 @@ test -x $DAEMON || exit 0 case $1 in start) echo -n "Starting PostgreSQL: " + test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1 echo "ok" ;; @@ -73,6 +82,7 @@ case $1 in restart) echo -n "Restarting PostgreSQL: " su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w" + test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1 echo "ok" ;; |