The caps are a systemd MemoryHigh=384M, MemoryMax=512M and no swap. Node sizes its heap from that cgroup limit, so the cap is also the heap ceiling.
What was wrong
Not growth. The pool held 11,940 rows on 2026-10-21 and 11,933 on 2026-10-23. The earlier runs had been started by hand with no cap, so this was the first run under the limit.
The real cause: the job kept the full judging input of every kept record until the end of the run. Each input held 90 saved days of readings in all countries, chart ranks and country history. The heap reached about 250 MB before the archive step started, and the archive step pushed it over the cap.
Method
We copied the real databases and reproduced the crash with the same caps through systemd-run. Then we fixed the code and ran the fix on the copy and in production. These are our own measurements.
The fix
The judge step now keeps 4 fields per record: the key, the subject, the row and a due flag. A small function rebuilds one record's full input only when a review reads that record. The last log line prints max_rss_mb. The caps stayed the same.
| Run | Result | Memory peak |
|---|---|---|
| Copy of real data, old code, same caps | heap out of memory | 389.9 MB |
| Copy of real data, fixed code, same caps | success, 11,933 rows, archive written | 259.2 MB |
| Production, fixed code | success in 2 min 58 s, 11,933 rows, archive written | 321 MB cgroup peak (includes SQLite page cache), max_rss_mb 246 |
Tests: 6 pass, 0 fail.
Steps for your own job
This applies to Node batch jobs that hold per-item data until the run ends and run under a systemd or container cap.
- When the job dies with "Reached heap limit", look at what it keeps per item before you raise the cap.
- Keep only the fields you need later. We kept 4.
- Write a small function that rebuilds the full input when something reads that item.
- Print max_rss_mb on the last log line so every run shows its distance to the limit.
What we lost
- 11,933 rows is a measured point, not a bound. The job has no stated item limit if the pool grows.
- One whole build is still held at once (about 13.5 MB of JSON) and gzipped in one piece. Streaming it was not worth the extra code at 246 MB.
- No warning fires when max_rss_mb nears the cap. Only a failed run pages.
- A second production timer run had not finished at the time of writing.
If you want a failed batch run to show up without anyone opening the log, Oddwatch reads logs each morning and flags runs like this one.
Frequently asked questions
What does our tool return when a batch run dies like this one?
Our tool reads the log each morning and flags the failed run, so it shows up without anyone opening the log. It does not warn when max_rss_mb nears the cap; in our setup only a failed run pages.
Why is the production cgroup peak 321 MB when max_rss_mb is 246?
The cgroup figure includes SQLite page cache, which max_rss_mb does not count. The cap applies to the cgroup, so both numbers matter.
Did you stream the archive instead?
No. One whole build, about 13.5 MB of JSON, is still held and gzipped in one piece. At 246 MB the extra code was not worth it.
Sources
- Based on our own checks, read 2026-10-26.