Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[batch] Use earlyoom to terminate a process using too much memory #1402

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

giordano
Copy link
Member

Linux's built-in system to manage out-of-memory (OOM) errors is unreliable and non-informative, even if it kicks in (and if often it does too late, when the machine is already unresponsive) there's no easy way to tell that a process on a remote machine was terminated because it was using too much memory. With earlyoom we bypass Linux's OOM management and have better control over what's printed to screen in case of error.

Ref: #1333 (comment).

Note: opening as draft because I haven't tested this in production yet.

Linux's built-in system to manage out-of-memory (OOM) errors is unreliable and
non-informative, even if it kicks in (and if often it does too late, when the
machine is already unresponsive) there's no easy way to tell that a process on a
remote machine was terminated because it was using too much memory.  With
`earlyoom` we bypass Linux's OOM management and have better control over what's
printed to screen in case of error.
# Terminate the `earlyoom` process
kill "${{{{EARLYOOM_PID}}}}"
# Print line(s) in the log file referencing terminated processes, if any.
grep "^sending SIGTERM to process" "${{{{EARLYOOM_LOG}}}}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This catches also SIGKILL:

Suggested change
grep "^sending SIGTERM to process" "${{{{EARLYOOM_LOG}}}}"
grep "^sending \w+ to process" "${{{{EARLYOOM_LOG}}}}"

Comment on lines +252 to +253
# Start the `earlyoom` daemon.
nohup earlyoom -m 95 -s 100 &> "${{{{EARLYOOM_LOG}}}}" &
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got the argument -m 5 backward, the argument is the amount of memory available, not used:

Suggested change
# Start the `earlyoom` daemon.
nohup earlyoom -m 95 -s 100 &> "${{{{EARLYOOM_LOG}}}}" &
# Start the `earlyoom` daemon. Ignore swap usage, terminate process if less than 5% of main memory available.
nohup earlyoom -m 5 -s 100 &> "${{{{EARLYOOM_LOG}}}}" &

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant