Skip to content

fix: systemd: set OOMPolicy=continue so an OOM kill does not destroy every session - #465

Open
lanshi17 wants to merge 1 commit into
shell-pool:masterfrom
lanshi17:systemd-oompolicy-continue
Open

lanshi17 wants to merge 1 commit into
shell-pool:masterfrom
lanshi17:systemd-oompolicy-continue

Conversation

@lanshi17

Copy link
Copy Markdown

Issue Link

#464

AI Policy Ack

I read the AI Policy. I used an AI coding agent interactively to analyze the OOM/systemd journal evidence and to draft this one-line unit change and the PR text. I reproduced the failure on my machine, reviewed the diff, and tested the change myself: systemd-analyze verify passes on systemd 259, and installing the setting as a drop-in plus systemctl --user daemon-reload updates a running unit (systemctl show -p OOMPolicy changes from stop to continue) without restarting the daemon.

This PR was:

  • mostly or completely vibe coded
  • mostly or completely meat coded
  • bit of both

Description

Add OOMPolicy=continue to the shipped user unit.

systemd/shpool.service uses the systemd default OOMPolicy=stop. The unit's cgroup contains the daemon and every session shell and its children, so a kernel OOM kill of any single process in a session stops the entire unit. With KillMode=mixed + SendSIGHUP=yes, that terminates the daemon and destroys every session; all shpool attach clients exit.

I hit this four times in one afternoon on a 31 GiB machine when a runaway ~20 GiB Python job inside one session exhausted RAM + swap:

shpool.service: The kernel OOM killer killed some processes in this unit.
shpool.service: Failed with result 'oom-kill'.
oom-kill: ... task_memcg=.../shpool.service, task=python, pid=964558
Out of memory: Killed process 964558 (python) anon-rss:21687856kB

With OOMPolicy=continue, only the OOM-killed process is lost; the daemon and the other sessions survive. This matches what users expect from a session pool: a runaway job in one pane should not kill every pane.

OOMPolicy= has been available since systemd v243; on older systemd the unknown key is ignored with a warning, so this does not add a hard version requirement.

Refs #464

The unit's cgroup contains the daemon and every session shell, so with the
default OOMPolicy=stop a kernel OOM kill of any single process in a session
stops the whole unit and destroys all sessions.

OOMPolicy=continue keeps the daemon and the unaffected sessions alive; only
the OOM-killed task is lost.

Refs shell-pool#464
@google-cla

google-cla Bot commented Nov 24, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@ethanpailes

Copy link
Copy Markdown
Contributor

LGTM, we just need that CLA sig and I can get this merged for you!

@ethanpailes ethanpailes changed the title systemd: set OOMPolicy=continue so an OOM kill does not destroy every session fix: systemd: set OOMPolicy=continue so an OOM kill does not destroy every session Nov 24, 2026
@ethanpailes

Copy link
Copy Markdown
Contributor

Oh also, we use canonical commits for automatic patchnote generation, so the prefix should be fix: for this guy. I also usually do subsystem: ... but the automation is nice for a project like this.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants