Skip to content

Strange oomd behavior with user services #21684

Closed

Description

@mrc0mmand

systemd version the issue has been seen with

latest main

Used distribution

Arch Linux (clang + ASAn/UBSan)

For the past couple of days (maybe a bit more) I've noticed a pattern in CentOS CI fails regarding TEST-55-OOMD. After going through several journals, there's a weird race(?) where oomd kills the "chill" service first, but only when running the user service tests (from what I've seen so far). Also note that all failed runs I have collected until now are with sanitizers.

Excerpt from one of the journals:

[   44.913895] testsuite-55.sh[364]: + systemctl start --machine [email protected] --user testsuite-55-testchill.service
[   53.055305] systemd[352]: Started D-Bus User Message Bus.
[   53.350162] systemd[352]: Created slice Slice /testsuite.
[   53.351331] systemd[352]: Created slice Slice /testsuite/55.
[   53.353631] systemd[352]: Created slice Test slice for memory pressure kills.
[   53.359316] systemd[352]: Started No memory pressure.
[   66.971253] testsuite-55.sh[466]: ● testsuite-55-testchill.service - No memory pressure
[   66.971253] testsuite-55.sh[466]:      Loaded: loaded (/usr/lib/systemd/tests/testdata/units/testsuite-55-testchill.service; static)
[   66.971253] testsuite-55.sh[466]:      Active: active (running) since Wed 2021-12-08 11:47:33 UTC; 13s ago
[   66.971253] testsuite-55.sh[466]:    Main PID: 448
[   66.971253] testsuite-55.sh[466]:       Tasks: 1 (limit: 2350)
[   66.971253] testsuite-55.sh[466]:      Memory: 3.1M
[   66.971253] testsuite-55.sh[466]:         CPU: 16ms
[   66.971253] testsuite-55.sh[466]:      CGroup: /user.slice/user-4711.slice/[email protected]/testsuite.slice/testsuite-55.slice/testsuite-55-workload.slice/testsuite-55-testchill.service
[   66.971253] testsuite-55.sh[466]:              └─448 sleep infinity
[   66.983076] testsuite-55.sh[472]: ++ date -ud '2 minutes' +%s
[   66.984625] testsuite-55.sh[364]: + timeout=1638964186
[   66.986399] testsuite-55.sh[473]: ++ date -u +%s
[   66.987588] testsuite-55.sh[364]: + [[ 1638964066 -le 1638964186 ]]
[   66.987588] testsuite-55.sh[364]: + systemctl --machine [email protected] --user status testsuite-55-testbloat.service
[   71.698773] systemd-oomd[404]: Killed /user.slice/user-4711.slice/[email protected]/testsuite.slice/testsuite-55.slice/testsuite-55-workload.slice/testsuite-55-testchill.service due to memory pressure for /user.slice/user-4711.slice/[email protected]/testsuite.slice/testsuite-55.slice/testsuite-55-workload.slice being 37.25% > 20.00% for > 2s with reclaim activity
[   71.702543] systemd[352]: testsuite-55-testchill.service: systemd-oomd killed 1 process(es) in this unit.
[   71.703532] systemd[352]: testsuite-55-testchill.service: Main process exited, code=killed, 
[   72.228426] systemd[352]: libbpf: load bpf program failed: Operation not permitted
[   72.380504] systemd[352]: libbpf: failed to load program 'restrict_filesystems'
[   72.612702] systemd[352]: libbpf: failed to load object 'restrict_fs_bpf'
[   72.612702] systemd[352]: libbpf: failed to load BPF skeleton 'restrict_fs_bpf': -1
[   72.615347] systemd[352]: Failed to load BPF object
[   73.652027] kernel: audit: type=1105 audit(1638964073.386:167): pid=476 uid=0 auid=4711 ses=5 msg='op=PAM:session_open grantors=pam_loginuid,pam_keyinit,pam_limits,pam_unix,pam_permit,pam_mail,pam_systemd,pam_env acct="testu>
[   73.893172] systemd[479]: pam_unix(login:session): session closed for user testuser
[   73.894486] testsuite-55.sh[474]: ● testsuite-55-testbloat.service - Create a lot of memory pressure
[   73.894486] testsuite-55.sh[474]:      Loaded: loaded (/usr/lib/systemd/tests/testdata/units/testsuite-55-testbloat.service; static)
[   73.894486] testsuite-55.sh[474]:      Active: active (running) since Wed 2021-12-08 11:47:39 UTC; 13s ago
[   73.894486] testsuite-55.sh[474]:    Main PID: 455
[   73.894486] testsuite-55.sh[474]:       Tasks: 1 (limit: 2350)
[   73.894486] testsuite-55.sh[474]:      Memory: 960.0K (high: 1.0M available: 64.0K)
[   73.894486] testsuite-55.sh[474]:         CPU: 6.821s
[   73.894486] testsuite-55.sh[474]:      CGroup: /user.slice/user-4711.slice/[email protected]/testsuite.slice/testsuite-55.slice/testsuite-55-workload.slice/testsuite-55-testbloat.service
[   73.894486] testsuite-55.sh[474]:              └─455 bash /usr/lib/systemd/tests/testdata/units/testsuite-55-slowgrowth.sh
[   73.910887] testsuite-55.sh[364]: + sleep 2
[   75.903891] testsuite-55.sh[483]: ++ date -u +%s
[   75.906955] testsuite-55.sh[364]: + [[ 1638964075 -le 1638964186 ]]
[   75.908136] testsuite-55.sh[364]: + systemctl --machine [email protected] --user status testsuite-55-testbloat.service
[   83.300763] testsuite-55.sh[484]: ● testsuite-55-testbloat.service - Create a lot of memory pressure
[   83.300763] testsuite-55.sh[484]:      Loaded: loaded (/usr/lib/systemd/tests/testdata/units/testsuite-55-testbloat.service; static)
[   83.300763] testsuite-55.sh[484]:      Active: active (running) since Wed 2021-12-08 11:47:39 UTC; 23s ago
[   83.300763] testsuite-55.sh[484]:    Main PID: 455
[   83.300763] testsuite-55.sh[484]:       Tasks: 1 (limit: 2350)
[   83.300763] testsuite-55.sh[484]:      Memory: 944.0K (high: 1.0M available: 80.0K)
[   83.300763] testsuite-55.sh[484]:         CPU: 7.383s
[   83.300763] testsuite-55.sh[484]:      CGroup: /user.slice/user-4711.slice/[email protected]/testsuite.slice/testsuite-55.slice/testsuite-55-workload.slice/testsuite-55-testbloat.service
[   83.300763] testsuite-55.sh[484]:              └─455 bash /usr/lib/systemd/tests/testdata/units/testsuite-55-slowgrowth.sh
[   83.323602] testsuite-55.sh[364]: + sleep 2
[   85.310899] testsuite-55.sh[491]: ++ date -u +%s
[   85.316163] testsuite-55.sh[364]: + [[ 1638964085 -le 1638964186 ]]
[   85.316163] testsuite-55.sh[364]: + systemctl --machine [email protected] --user status testsuite-55-testbloat.service
[   86.945881] systemd-oomd[404]: Killed /user.slice/user-4711.slice/[email protected]/testsuite.slice/testsuite-55.slice/testsuite-55-workload.slice/testsuite-55-testbloat.service due to memory pressure for /user.slice/user-47>
[   86.955795] systemd[352]: testsuite-55-testbloat.service: systemd-oomd killed 1 process(es) in this unit.
[   86.956560] systemd[352]: testsuite-55-testbloat.service: Main process exited, code=killed, status=9/KILL
[   86.956802] systemd[352]: testsuite-55-testbloat.service: Failed with result 'signal'.

Usually I would say this is a side-effect of a sanitized build, but the fact it happens only with user services is a bit strange.

Full journals:

/cc @anitazha

Activity

  1. added
    bug 🐛
    on Dec 8, 2021
  2. self-assigned this
    on Dec 8, 2021
  3. added this to the v250 milestone on Dec 16, 2021
  4. anitazha commented on Dec 17, 2021

    @anitazha
    Member

    I think I see what's happening here. For some reason the sleep call done by the user service is using 3M of memory while in the system service case it is using 200K. MemoryHigh=1M on testbloat so it throttles to 1M. If neither are increasing in pgscan but pressure is over the threshold then oomd will sort by memory usage and could end up targeting testchill. I think this can be easily fixed by adjusting MemoryHigh= on the test units.

  5. bluca commented on Dec 17, 2021

    @bluca
    Member

    Thanks for having a look! Can you send a PR to do that?

  6. anitazha commented on Dec 17, 2021

    @anitazha
    Member

    Yup testing it out right now

  7. added a commit that references this issue on Dec 17, 2021
    30818d9
  8. added a commit that references this issue on Dec 17, 2021
    415d7d7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐛ci-blocker 🚧oomd

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions