[GH-ISSUE #4051] Arena load proceeds with 10 GiB MemAvailable for 40 GiB and wedges the whole host (jbd2 + every D-state task) instead of refusing #1750

Closed
opened 2026-11-04 01:53:44 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @notphotograph-a11y on GitHub (Oct 25, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4051

Summary

On a 60 GiB host with a 40 GiB expert arena, the engine started a new instance while the previous one's memory was still resident (current 50.3 GiB, available 10.1 GiB), then allocated the full 39.97 GiB arena. The kernel went into global reclaim, jbd2 blocked on the root filesystem, every disk-touching task went to D state, and the machine had to be power-cycled after ~21 hours. expert_source.cpp already refuses when the cgroup limit is below need; when available is below need it only warns, and that warning case is exactly what killed this host.

Environment

  • engine 0.1.45, source build (sm_86, CUDA 13.1); serve/server.py + engine/strata + strata-vision
  • model Qwen3.8-Flash-Next IQ3_XXS, --max-context 131072, --spec 4, --expert-cache auto, --vram-reserve-mib 700
  • Ubuntu 26.04, kernel 7.0.0-38-generic, 60.4 GiB RAM, 8 GiB swap, RTX 3090 24 GB, root on Samsung 970 EVO 250 GB (ext4)
  • idle_unload_s: 1000, so the engine unloads when idle and reloads on the next request — this reload is what ran into the still-exiting instance
  • checked against v0.2.4.2: src/core/expert_source.cpp has the same two branches (see below), so this is not already fixed in master

Timeline

22:10:02  sar: MemAvailable 11.2 GiB, no swap activity, CPU 99.9% idle
22:18:56  [strata] engine started: .../engine/strata --serve --pack .../packs/iq3_xxs ...
          strata generate: memory guard: limit 60.4 GiB (source: meminfo), current 50.3 GiB,
                           reclaimable cache credited 0.0 GiB; available 10.1 GiB
                           (MemAvailable 10.1 GiB), floor 2560 MiB
          strata: expert arena: MAP_HUGETLB unavailable (needed 20464 2 MiB pages, vm.nr_hugepages=0);
                  ... only 2 GiB of free 2 MiB blocks for a 39 GiB arena ...
          strata generate: loaded 39.97 GiB at 0.52 GiB/s
22:21:14  systemd-journald: Under memory pressure, flushing caches.        (repeats until 22:25)
22:22-25  swap/reclaim storm; node_exporter "write: broken pipe" to the scraper
22:25:26  last journal line; the machine never logged again
          console:
            INFO: task jbd2/nvme1n1p2 blocked for more than 122 seconds.
            jbd2_journal_wait_updates -> jbd2_journal_commit_transaction -> kjournald2
            INFO: task systemd-journald / rsyslogd / node_exporter blocked ...

From outside: ICMP fine (0% loss, 14 ms), TCP handshakes to 22 and 8080 completed, but zero bytes came back on either for 25 s per attempt, repeatedly, for ~21 h. No shell, no HTTP. Only a hard reset recovered it.

The disk is not the cause

  • no nvme I/O timeout, no controller reset, no media error, no EXT4-fs error in any boot's journal
  • 642 MB/s sequential read (O_DIRECT, 2 GiB), 4 KiB random reads p50 0.20 ms / p90 0.22 ms
  • nvme1n1p2: recovering journal after the reset is the expected result of the reset itself

jbd2 blocked because the journal could not commit while the system was stalled in reclaim — it is a symptom, not the origin.

Why I think this is a bug and not a documented limit

src/core/expert_source.cpp (identical at v0.1.45 and v0.2.4.2):

if (hm.cgroup_limit < need) { ... "it would be killed while loading" ...; return false; }   // hard stop
if (hm.available   < need) { ram_warning_ = buf; }                                          // warning only

with the comment: "Less RAM available than the arena (another program, an engine still exiting) is only a warning - the OS may make room - per the recommend-not-force rule."

On a host whose RAM is only 1.5x the arena, "the OS may make room" is false: it cannot, and the failure mode is not a failed start but a machine that must be power-cycled. The comment even names this exact case ("an engine that is still exiting"). Since the server itself restarts the engine (idle unload → reload, or its own restart path), this is reachable without anyone doing anything unusual.

Suggested fixes

  1. Treat available < need as fatal when the shortfall is larger than what reclaim could plausibly return (e.g. available < need / 2), or wait for the exiting engine with a bounded timeout and retry, then fail.
  2. Serialize engine restarts on the old engine's RSS actually reaching zero (the guard already reports current; using it as a gate would have stopped this start).
  3. Consider documenting the cgroup workaround below in DETAILS.md next to the memory-guard paragraph for hosts near the RAM limit.

Workaround applied here (works, but the engine should not need it)

systemctl set-property strata.service MemoryHigh=50G MemoryMax=54G MemorySwapMax=0
# plus, so a wedge reboots instead of hanging for a day:
sysctl kernel.hung_task_panic=1 kernel.hung_task_timeout_secs=120 kernel.panic=10

MemorySwapMax=0 is the part that matters: with swap available, the kernel thrashes for hours instead of OOM-killing the one process that ran away.

Originally created by @notphotograph-a11y on GitHub (Oct 25, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4051 ## Summary On a 60 GiB host with a 40 GiB expert arena, the engine started a new instance while the previous one's memory was still resident (`current 50.3 GiB`, `available 10.1 GiB`), then allocated the full `39.97 GiB` arena. The kernel went into global reclaim, `jbd2` blocked on the root filesystem, every disk-touching task went to D state, and the machine had to be power-cycled after ~21 hours. `expert_source.cpp` already refuses when the **cgroup** limit is below `need`; when `available` is below `need` it only warns, and that warning case is exactly what killed this host. ## Environment - engine 0.1.45, source build (`sm_86`, CUDA 13.1); `serve/server.py` + `engine/strata` + `strata-vision` - model Qwen3.8-Flash-Next IQ3_XXS, `--max-context 131072`, `--spec 4`, `--expert-cache auto`, `--vram-reserve-mib 700` - Ubuntu 26.04, kernel 7.0.0-38-generic, 60.4 GiB RAM, 8 GiB swap, RTX 3090 24 GB, root on Samsung 970 EVO 250 GB (ext4) - `idle_unload_s: 1000`, so the engine unloads when idle and reloads on the next request — this reload is what ran into the still-exiting instance - checked against v0.2.4.2: `src/core/expert_source.cpp` has the same two branches (see below), so this is not already fixed in master ## Timeline ``` 22:10:02 sar: MemAvailable 11.2 GiB, no swap activity, CPU 99.9% idle 22:18:56 [strata] engine started: .../engine/strata --serve --pack .../packs/iq3_xxs ... strata generate: memory guard: limit 60.4 GiB (source: meminfo), current 50.3 GiB, reclaimable cache credited 0.0 GiB; available 10.1 GiB (MemAvailable 10.1 GiB), floor 2560 MiB strata: expert arena: MAP_HUGETLB unavailable (needed 20464 2 MiB pages, vm.nr_hugepages=0); ... only 2 GiB of free 2 MiB blocks for a 39 GiB arena ... strata generate: loaded 39.97 GiB at 0.52 GiB/s 22:21:14 systemd-journald: Under memory pressure, flushing caches. (repeats until 22:25) 22:22-25 swap/reclaim storm; node_exporter "write: broken pipe" to the scraper 22:25:26 last journal line; the machine never logged again console: INFO: task jbd2/nvme1n1p2 blocked for more than 122 seconds. jbd2_journal_wait_updates -> jbd2_journal_commit_transaction -> kjournald2 INFO: task systemd-journald / rsyslogd / node_exporter blocked ... ``` From outside: ICMP fine (0% loss, 14 ms), TCP handshakes to 22 and 8080 completed, but **zero bytes** came back on either for 25 s per attempt, repeatedly, for ~21 h. No shell, no HTTP. Only a hard reset recovered it. ## The disk is not the cause - no `nvme` I/O timeout, no controller reset, no media error, no `EXT4-fs error` in any boot's journal - 642 MB/s sequential read (O_DIRECT, 2 GiB), 4 KiB random reads p50 0.20 ms / p90 0.22 ms - `nvme1n1p2: recovering journal` after the reset is the expected result of the reset itself `jbd2` blocked because the journal could not commit while the system was stalled in reclaim — it is a symptom, not the origin. ## Why I think this is a bug and not a documented limit `src/core/expert_source.cpp` (identical at v0.1.45 and v0.2.4.2): ```cpp if (hm.cgroup_limit < need) { ... "it would be killed while loading" ...; return false; } // hard stop if (hm.available < need) { ram_warning_ = buf; } // warning only ``` with the comment: *"Less RAM available than the arena (another program, an engine still exiting) is only a warning - the OS may make room - per the recommend-not-force rule."* On a host whose RAM is only 1.5x the arena, "the OS may make room" is false: it cannot, and the failure mode is not a failed start but a machine that must be power-cycled. The comment even names this exact case ("an engine that is still exiting"). Since the server itself restarts the engine (idle unload → reload, or its own restart path), this is reachable without anyone doing anything unusual. ## Suggested fixes 1. Treat `available < need` as fatal when the shortfall is larger than what reclaim could plausibly return (e.g. `available < need / 2`), or wait for the exiting engine with a bounded timeout and retry, then fail. 2. Serialize engine restarts on the old engine's RSS actually reaching zero (the guard already reports `current`; using it as a gate would have stopped this start). 3. Consider documenting the cgroup workaround below in DETAILS.md next to the memory-guard paragraph for hosts near the RAM limit. ## Workaround applied here (works, but the engine should not need it) ```bash systemctl set-property strata.service MemoryHigh=50G MemoryMax=54G MemorySwapMax=0 # plus, so a wedge reboots instead of hanging for a day: sysctl kernel.hung_task_panic=1 kernel.hung_task_timeout_secs=120 kernel.panic=10 ``` `MemorySwapMax=0` is the part that matters: with swap available, the kernel thrashes for hours instead of OOM-killing the one process that ran away.
bsakaguchi 2026-11-04 01:53:44 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 25, 2026):

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes".

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6392190027 --> @github-actions[bot] commented on GitHub (Oct 25, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes". Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@Niko1221 commented on GitHub (Oct 29, 2026):

Thank you for the timeline and the cgroup workaround. The server ended the engine of the earlier run but waited only 10 s after the kill; an engine with tens of GB pinned needs longer, so the new engine's memory guard saw current 50.3 GiB and loaded into it. Fixed on our side; the fix ships in the next update (0.2.8). The server now waits up to 120 s for such an engine to be gone, and the engine waits up to 20 s for the RAM to come back (STRATA_ARENA_RAM_WAIT_S, 0 loads at once).

Not changed: with the RAM really missing, the load still goes on after the warning (we recommend, never force). We did not start an engine on a 60 GiB host, so the wedge itself was not reproduced.

<!-- gh-comment-id:6492073486 --> @Niko1221 commented on GitHub (Oct 29, 2026): Thank you for the timeline and the cgroup workaround. The server ended the engine of the earlier run but waited only 10 s after the kill; an engine with tens of GB pinned needs longer, so the new engine's memory guard saw `current 50.3 GiB` and loaded into it. Fixed on our side; the fix ships in the next update (0.2.8). The server now waits up to 120 s for such an engine to be gone, and the engine waits up to 20 s for the RAM to come back (`STRATA_ARENA_RAM_WAIT_S`, 0 loads at once). Not changed: with the RAM really missing, the load still goes on after the warning (we recommend, never force). We did not start an engine on a 60 GiB host, so the wedge itself was not reproduced.
Author
Owner

@Niko1221 commented on GitHub (Oct 29, 2026):

Fixed in 0.2.8: the server now waits up to 120 s for the old engine to be gone, and the engine waits up to 20 s for the RAM to come back (STRATA_ARENA_RAM_WAIT_S; 0 loads at once). If the RAM is really missing, the load still goes on after a warning, because we warn rather than refuse. We could not reproduce the full wedge on a 60 GiB host. Run strata update. Closing; reopen if it wedges again.

<!-- gh-comment-id:6510321756 --> @Niko1221 commented on GitHub (Oct 29, 2026): Fixed in 0.2.8: the server now waits up to 120 s for the old engine to be gone, and the engine waits up to 20 s for the RAM to come back (`STRATA_ARENA_RAM_WAIT_S`; 0 loads at once). If the RAM is really missing, the load still goes on after a warning, because we warn rather than refuse. We could not reproduce the full wedge on a 60 GiB host. Run `strata update`. Closing; reopen if it wedges again.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#1750
No description provided.