supermemory icon indicating copy to clipboard operation
supermemory copied to clipboard

supermemory-server (local, v0.0.8): unbounded memory growth → OOM every few hours; DB stuck on 'cannot drop active portal' after restart

Open skillet07 opened this issue 1 month ago • 5 comments

Summary

supermemory-server (local / lite) grows its memory without bound on a small, mostly idle dataset and gets OOM-killed by its cgroup limit every 4–22 hours. Once (after one such OOM restart) the embedded database got stuck returning cannot drop active portal "" on every query, so /v3/search answered 500 for ~2 days until a manual restart.

Environment

  • supermemory-server v0.0.8 (upgraded from v0.0.3 via supermemory-server upgrade), lite license
  • Ubuntu 24.04.4 LTS, kernel 6.8.0, x86_64, 4 vCPU, 8 GB RAM, 2.5 GB swap
  • Runs as a systemd user unit on 127.0.0.1:6767, single client (Hermes agent memory plugin: auto recall + auto capture, hybrid search)
  • Embeddings: local Xenova/bge-base-en-v1.5 (768d)
  • Data dir ~600 MB on disk; 616 documents total, one container tag
  • Env: SUPERMEMORY_EMBEDDING_RAM_LIMIT=512mb, SUPERMEMORY_INGEST_CONCURRENCY=1, SUPERMEMORY_LOCAL_EMBEDDING_POOL_SIZE=1, SUPERMEMORY_LOCAL_EMBEDDING_WASM_THREADS=1, SUPERMEMORY_LOCAL_EMBEDDING_BATCH_SIZE=4, SUPERMEMORY_LOCAL_EMBEDDING_MAX_BATCHES_BEFORE_RECYCLE=4
  • cgroup limits: MemoryMax=3500M, MemorySwapMax=512M, no MemoryHigh

1. Unbounded memory growth → OOM kill

  • Startup peak ≈ 3.4 GB, then settles at ~2.0–2.25 GB (anon ≈ 1.6–1.8 GB, rest page cache). Startup log: [ingest] memory limit 0.5 GB above baseline (1.7 GB).
  • After that anon memory keeps growing while the document count barely changes (511 → 616 docs over 9 days), until the cgroup limit (3.5 GB + 512 MB swap) is hit and the kernel OOM-kills the process.
  • OOM kills on v0.0.8: Oct 10, Oct 12, Oct 13, Oct 15, Oct 16 (×3) – intervals between 4 h and ~2 days, typically under 1 day.
  • Two more crashes ended in core dumps: status=4/ILL (Oct 11) and status=5/TRAP (Oct 13).
  • v0.0.3 showed the same pattern: after 2.7 days uptime it had 1.7 GB RSS + 2.1 GB swapped out (it was capped at 1800M and ended up thrashing in swap, not accepting connections on 6767).

616 small documents needing 2 GB at baseline and growing past 4 GB looks like a leak rather than a sizing problem.

2. DB stuck in cannot drop active portal "" after an OOM restart

After the OOM restart on Oct 13 15:13, every DB query failed until a manual restart on Oct 15:

error: cannot drop active portal ""
   severity: "ERROR",
      query: "select \"id\", \"status\", \"processing_metadata\" from \"document\" where ((\"document\".\"status\" in ($1, $2, $3, $4) ...
[Cron] Starting stuck/failed dreaming job retry
error: Failed query: select "dreaming_job"."batch_id", "dreaming_job"."org_id", "dreaming_job"."container_tag", min("dreaming_job"."processing_started_ ...
Search error: (FiberFailure) VectorDBError: Failed to search chunks (namespace: <org>_chunks_<tag>)
  [cause]: Error: Failed query: select "id" from "document" where ("document"."org_id" = $1 and "document"."container_tags" @> ARRAY[$2]::text[])
    [cause]: error: cannot drop active portal ""
error: Search failed: Failed to search chunks (namespace: <org>_chunks_<tag>)

POST /v3/search → 500 {"error":"Invalid search parameters or database error","code":"SEARCH_ERROR"}. 6–60 such errors per hour for ~44 h. A plain systemctl restart fixed it (search 200 in ~0.1 s, all documents present); it has not reappeared after the 4 OOM restarts since.

3. Minor (v0.0.3, before upgrade)

Hourly retry cron marked 342 jobs Permanently failed (no retry params key); those documents were never re-processed after upgrading.

Expected

Stable memory for a small dataset (or a documented way to cap it), and the server recovering by itself (or exiting so the supervisor restarts it) when the DB connection gets into the cannot drop active portal state.

Happy to collect more data (heap snapshot, specific env flags) if you tell me what would help.

skillet07 avatar Oct 17 '26 08:10 skillet07

ENG-1318

linear-code[bot] avatar Oct 17 '26 08:10 linear-code[bot]

Same crash class on server-v0.0.8 (linux-x64; corrected from 0.0.9: the boot line reads update available: v0.0.8 → v0.0.9, 8 GB box): 5 core-dumps 2026-10-22..24 (status=4/ILL, "oh no: Bun has crashed").

The root cause looks like the embedded runtime: every server build we checked (0.0.5, 0.0.7, 0.0.8, 0.0.9-rc.3, 0.0.9) embeds Bun v1.3.4 (5eb2145b), including 0.0.7, whose notes for #1456 said it shipped "a newer Bun runtime". Bun 1.4.0 removed libpas (the pas panic source) and 1.4.4 has more GC fixes on Linux.

Latest decoded trace (https://bun.report/1.3.4/la15eb2145mgEuhooCkyo8vE+ypRmi9yuEs9y4jF+2sjkFy8+ikFymnvjF2g0ujF4wz2jF632hkFyry2jF6932jF0l30tFm7h7hEq7n63Euo4g3E___0rztgEA2AA): segfault at 0x0 in pas_system_heap_allocate ← MarkedSpace::forEachWeakInParallel ← GC triggered by new Uint8Array(n). It was preceded by TypeError: Invalid header name: 'access-control-expose-headers<garbage bytes containing /tmp/pglite/... paths>', so the heap was already corrupted. BUN_JSC_useConcurrentGC=0 and Malloc=1 did not help.

Could you publish a server build on Bun >= 1.4.4? Happy to test an rc. And if that isn't planned soon: is repacking the shipped bundle on a newer Bun permitted under the lite licence?

Update: the crashes are phase-locked to the whole-DB snapshot. With the snapshot interval at 300 s (byte-patched from the hardcoded 10 s, since there's no knob for it), 12 of 14 core-dumps hit 5–83 s after a multiple of 300 s of process uptime (p ≈ 5e-6). Three decoded stacks die in the snapshot path's new Uint8Array(n). A configurable snapshot interval, or incremental persistence instead of a full dumpDataDir each tick, would help a lot alongside the Bun bump. Malloc=1 made things worse for us (rate about 4x), so others shouldn't try it.

brenthorn avatar Oct 24 '26 04:10 brenthorn

Following up on my comment above with what we've found since, and three concrete asks.

1. A server build on Bun >= 1.4.4. We checked both the v0.0.8 and v0.0.9 linux-x64 assets: each embeds Bun v1.3.4 (5eb2145b). Bun 1.4.4 (announced 2026-10-24) fixes three security advisories affecting 1.4.3 and earlier: compromised eMudhra certs, a brotli decoder bug, and HTTP/3 header handling. Bun recommends rebuilding bun build --compile executables. Bun 1.4 also drops libpas, which shows up in our earlier traces.

2. A snapshot-interval setting. 14 core-dumps since 2026-10-13. 12 of them landed 5–83 s after a snapshot tick (interval byte-patched to 300 s; p ≈ 5e-6). Three decoded stacks end in the gzip step's new Uint8Array(n), inside dumpTar → CompressionStream. Trimmed frames: pas_system_heap_allocate ← WTF::fastMalloc ← MarkedSpace::forEachWeakInParallel ← Heap::addCoreConstraints ← … collectIfNecessaryOrDefer ← reportExtraMemoryAllocatedSlowCase ← JSGenericTypedArrayView<Uint8Adaptor>::createUninitialized ← operationNewUint8ArrayWithOneArgument

3. Is WORKFLOW_ENGINE=direct supported long term? Every Invalid header name: 'access-control-expose-headers<garbage>' error was thrown at rivetkit's Registry.handler (new Response(…, {headers: f.headers})), where the headers come from the napi addon. Our inference: memory corruption is involved there. The v0.0.8 doctor suggests direct. Is it safe to run in production?

If a rebuild isn't planned soon, the licence question above stands: may self-hosters repack the shipped bundle on a newer Bun for single-host use? We won't do it without your OK.

Happy to test an rc on Linux x64 and share logs.

brenthorn avatar Oct 24 '26 13:10 brenthorn

Adding a pinned-release observation and recovery questions to this existing thread rather than opening a duplicate. Our Docker state reported OOMKilled=false; we have not established that our crash shares the OOM, snapshot or allocator mechanism discussed here. Related earlier threads: #1320 and #1456.

Additional observation: server-v0.0.9 Linux x64 segmentation panic and recovery questions

We evaluated the supplied self-hosted server-v0.0.9 Linux-x64 binary in an isolated local Docker benchmark with local OpenAI-compatible inference. The native process terminated with a Bun 1.3.4 segmentation panic; Docker reported exit code 132, OOMKilled=false and restart count 0. We have not established the underlying runtime defect or mapped the panic to a specific source operation.

Release provenance:

  • Binary SHA256: d7987ecbf2b024c6de9d167becbcfcaabce447169b41d6f56db86f87d5187984.
  • Supplied manifest backend commit: e3abf004d3c7c207ffefc746405cad4751e69e82; source visibility private.
  • Build run 38274189337, attempt 2.

The API accepted 1,828 document submissions, but logs established only 13 completed full workflows before failure. We do not equate acceptance, intermediate workflow folders or process existence with completed ingestion. The stopped container, volume, manifest and captures are preserved; we have not restarted it, resubmitted the documents or submitted the binary's crash-report link.

Please clarify for this exact release:

  1. Is restarting the same preserved store after this kind of abrupt native termination supported?
  2. Which document/workflow endpoint or durable state proves native completion, and how can queued/in-flight/failed workflows be reconciled without resubmission?
  3. Does a stable document custom ID guarantee idempotence of extraction, embeddings, graph/history and workflow steps across crash recovery, or only deduplicate initial document creation?
  4. Is an inspectable source/debug build or a known fixed release available for this panic class, with migration/backup instructions?

We can prepare a small synthetic reproduction once the supported diagnostic/recovery procedure is known. No corpus, credentials, private captures, native database or binary sample is attached to this comment. We would prefer a supported private diagnostic channel before sharing potentially sensitive logs. This is not a claim of data corruption or malicious behavior.

cameronmichaelharper-ai avatar Oct 25 '26 04:10 cameronmichaelharper-ai

Another data point, this time from native Windows (server-v0.0.8 supermemory-server-windows-x64.exe, sha256 d8fb2ac0…71c47, embeds Bun 1.3.4+5eb2145b), lite license, 64 GB Windows 11 box.

  • Single store, ~480 MB data file on disk, local embeddings Xenova/bge-base-en-v1.5 (768d), extractor on an OpenAI-compatible endpoint, Hermes agent memory plugin with auto recall + auto capture from about 20 agent profiles.
  • With default settings, private memory grows without bound under agent load. Before we had a guard, one process reached 85 GB committed / 40 GB working set in about 1.5 days (23.–24.10.), starved the whole machine and stopped answering on 6767.
  • Since then a watchdog restarts the server above 12 GB private. On a busy night (29.–30.10.) it fired 3 times in 8 h (12.1, 13.7 and 14.0 GB). After the 06:00 restart it grew to 3.7 GB by 06:41 and 4.9 GB by 06:43, so about 1.2 GB in 2 minutes, while the on-disk store stayed the same size.
  • Mitigation that helps so far: the same env as the original report (SUPERMEMORY_EMBEDDING_RAM_LIMIT=512mb, SUPERMEMORY_INGEST_CONCURRENCY=1, SUPERMEMORY_LOCAL_EMBEDDING_POOL_SIZE=1, SUPERMEMORY_LOCAL_EMBEDDING_WASM_THREADS=1, SUPERMEMORY_LOCAL_EMBEDDING_BATCH_SIZE=4, SUPERMEMORY_LOCAL_EMBEDDING_MAX_BATCHES_BEFORE_RECYCLE=4). After restart it peaked at ~5 GB and settled at ~2.6 GB, flat over the first 6+ minutes under the same load. I'll report back if it creeps.

+1 to the ask for a server build on Bun >= 1.4.4, and for a native Windows 0.0.9 (or later) build once that lands. The 0.0.9 notes say Windows stays on 0.0.8, so Windows users currently have no upgrade path.

nattiini45 avatar Oct 30 '26 05:10 nattiini45