Repository navigation
Description
What happened
Our long-running, shared Kubernetes Dagger engine (v0.21.9) grew from a ~1 GiB Go heap shortly after startup to ~23–30 GiB of allocated heap over ~26 hours. Container RSS rose to ~37 GiB, then the engine hit its 50 GB (decimal) container memory limit and was OOMKilled. Structural DAGQL cache pruning does not appear to substantially lower the retained heap.
We'd appreciate help identifying which objects retain the schema-heavy heap after clients have disconnected, and whether there is a fix or additional diagnostic we should run. We cannot yet identify a minimal reproducer; the workload is multiple CI jobs using a shared engine.
Measurements (all UTC, same engine container)
| Time | Connected clients | Go heap alloc | Container RSS | DAGQL metadata estimate | Single short-window Pyroscope in-use heap profile |
|---|---|---|---|---|---|
| Sep 24 11:00 (4 min after start) | 3 | ~0.9 GiB | ~1.7 GiB | ~0.2 GiB | ~0.94 GB |
| Sep 25 03:00 | 0 | ~10.7 GiB | ~17.4 GiB | ~0.7 GiB | ~10.33 GB |
| Sep 25 13:00 | 0 | ~23.2 GiB | ~35.2 GiB | ~0.9 GiB | ~22.95 GB |
| Sep 25 13:12 | — | — | ~44.7 GiB | — | Container usage reached 49.999 GB against a 50 GB limit; Kubernetes recorded OOMKilled at 13:12:23. |
At 02:54–03:05 on Sep 25, the connected-client gauge stayed at zero, RSS stayed ~17.4 GiB, and heap alloc oscillated around ~10.7–12 GiB even though go_memstats_last_gc_time_seconds advanced roughly every two minutes. At 12:58–13:00 clients were again zero, and the heap floor was ~23 GiB. The goroutine profile gauge was ~54 at both 03:00 and 13:00 (not a sustained goroutine-count increase). These are snapshots of the client gauge, not proof that all background activity stopped.
A separate structural pruning observation on Sep 27: dagger_dagql_cache_metadata_estimated_bytes dropped from ~0.468 GiB at 13:42 to ~0.269 GiB at 13:43, while RSS rose from ~15.1 GiB to ~15.6 GiB and the Go heap continued oscillating around ~8–13 GiB. Single short-window in-use heap profiles at 13:39 and 13:49 were ~7.47 GB and ~8.01 GB, with almost the same leading allocation sites. We understand that the metadata metric is a coarse estimate of cache-owned metadata, not the whole Go heap; the observation is that pruning alone is insufficient to return the engine close to its fresh-state memory usage.
What the heap profiles show
These are memory:inuse_space profiles queried over 15-second windows to avoid summing many snapshots. At Sep 25 13:00 with zero reported clients, the leading flat allocation sites included:
maps.clone: ~2.92 GBdagql.FieldSpec.FieldDefinition: ~2.50 GB (cumulative ~8.21 GB)dagql.InputSpecs.ArgumentDefinitions: ~2.27 GB (cumulative ~4.60 GB)hashicorp/go-set/v3.(*TreeSet).Insert: ~1.91 GBcore.(*SourceMap).TypeDirective: ~1.85 GBdagql.(*Server).Fork: ~0.61 GB (cumulative ~3.87 GB)dagql.Class.TypeDefinition: ~0.60 GB (cumulative ~8.87 GB)
At Sep 25 03:00, the ranking was similar, but smaller: maps.clone ~1.37 GB, FieldDefinition ~1.17 GB, ArgumentDefinitions ~1.06 GB, TreeSet.Insert ~0.96 GB, and TypeDirective ~0.89 GB. At Sep 24 11:00 the profile total was ~0.94 GB; cache import and much smaller schema-related sites were visible. The profiles identify allocation sites, not retention roots, so we cannot conclude that Server.Fork or SchemaForView themselves are leaking.
The engine reported go_gc_gomemlimit_bytes = 9223372036854775807 (default unlimited) and GOGC=100 before the OOM. We are considering a lower Go memory limit as a mitigation but want to address the retained heap.
Configuration
- Engine image
registry.dagger.io/engine:v0.21.9, Kubernetes memory limit50G. - Engine JSON includes
gc.dagqlCache.maxEstimatedBytes=1073741824andtargetEstimatedBytes=805306368(1 GiB / 0.75 GiB); other GC settings use defaults. - Local disk cache is on a host volume. The
dagger_local_cache_total_disk_size_bytesmetric rose from ~47 GiB to ~403 GiB across the same ~26 hours, so we cannot exclude a relationship with retained cache/session state.
Questions
- Is there a known retention path for per-client/session
Server.Fork/ built schemas or module type definitions after clients disconnect in v0.21.9? What keeps those objects alive? - Are there recommended metrics or heap diagnostics (e.g. a profile diff after forcing GC, or specific cache/session counters) that distinguish retained session schemas from normal persistent-cache ownership?
- Is there a fix available for this version, or a safe configuration/operational workaround beyond pruning the DAGQL cache metadata?
I can supply additional anonymized profiles, metrics, or a narrower workload comparison if useful. Internal dashboards cannot be linked publicly.
Activity
tmablunar commentedon Sep 28, 2026
Clarification after checking the entire client-gauge series (rather than inferring an interval from two snapshots):
dagger_connected_clientsis scraped approximately every 30 seconds. Overnight Sep 24 22:48–Sep 25 05:34 UTC, it was zero at most scrapes, but not continuously: short nonzero readings occurred at 22:49 (max 1), 00:53 (1), 01:30 (2), 03:54 (1), 04:34 (2), 04:44–04:47 (1), and 05:32–05:33 (2). The longest uninterrupted observed zero stretch was 01:31–03:54 (~2h23m); another was 22:49–00:53 (~2h04m). Across that long overnight stretch RSS stayed near 17.4–17.6 GiB; heap allocation oscillated around ~10.7–12 GiB and GC continued. After 05:34, connections became frequent; between 06:00 and 13:00 there were many nonzero readings (peaking at 9). In particular, zero clients at 13:00 was only a momentary observation: the gauge read 5 at 12:57, 2 at 13:00:30, and 4 at 13:01. Thus the 13:00 profile establishes a high heap during a brief zero-client reading, not prolonged idleness. Samples can miss connections shorter than the scrape interval, and zero clients does not prove the engine had no background work.[-]Engine v0.21.9: schema-heavy Go heap grows while clients are disconnected; DAGQL metadata prune does not reclaim it[/-][+]Engine v0.21.9: schema-heavy heap persists through multi-hour zero-client periods; DAGQL prune does not reclaim it[/+]