diff options
author | Tom Lane | 2012-06-13 19:34:57 +0000 |
---|---|---|
committer | Tom Lane | 2012-06-13 19:35:52 +0000 |
commit | 93f4d7f806613d28842f956a84f31cc41d825503 (patch) | |
tree | 493db7fa8fc449a9cac2a75ac2a44b197e9f2271 /contrib/start-scripts/linux | |
parent | b9212e379c55564c8b6cdc8585b74606e90ec1ea (diff) |
Support Linux's oom_score_adj API as well as the older oom_adj API.
The simplest way to handle this is just to copy-and-paste the relevant
code block in fork_process.c, so that's what I did. (It's possible that
something more complicated would be useful to packagers who want to work
with either the old or the new API; but at this point the number of such
people is rapidly approaching zero, so let's just get the minimal thing
done.) Update relevant documentation as well.
Diffstat (limited to 'contrib/start-scripts/linux')
-rw-r--r-- | contrib/start-scripts/linux | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/contrib/start-scripts/linux b/contrib/start-scripts/linux index 4ad66917e65..b950cf512c3 100644 --- a/contrib/start-scripts/linux +++ b/contrib/start-scripts/linux @@ -42,10 +42,14 @@ 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. +# of the way it accounts for shared memory). Setting the OOM_SCORE_ADJ value +# to -1000 will disable OOM kill altogether. If you enable this, you probably +# want to compile PostgreSQL with "-DLINUX_OOM_SCORE_ADJ=0", so that +# individual backends can still be killed by the OOM killer. +#OOM_SCORE_ADJ=-1000 +# Older Linux kernels may not have /proc/self/oom_score_adj, but instead +# /proc/self/oom_adj, which works similarly except the disable value is -17. +# For such a system, enable this and compile with "-DLINUX_OOM_ADJ=0". #OOM_ADJ=-17 ## STOP EDITING HERE @@ -78,6 +82,7 @@ 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 su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1 echo "ok" @@ -90,6 +95,7 @@ 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 su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1 echo "ok" |