Skip to content

fix(documentstore): eliminate OOM during vectorstore upsert of large stores - #1031

Merged
maxtechera merged 1 commit into
stagingfrom
fix/kumello-68-upsert-oom
Mar 17, 2026
Merged

fix(documentstore): eliminate OOM during vectorstore upsert of large stores#1031
maxtechera merged 1 commit into
stagingfrom
fix/kumello-68-upsert-oom

Conversation

@maxtechera

Copy link
Copy Markdown
Collaborator

Summary

Fixes OOM crash during Pinecone upsert of large document stores (95k+ chunks). Memory climbed steadily from baseline to 2GB over ~1 hour until SIGKILL.

Root Cause

Three compounding memory leaks during vectorstore upsert:

  1. addedDocs accumulation (indexing.ts:305) — every batch pushed full Document objects into an array never freed. 95k chunks x ~5KB = ~475MB.
  2. indexResult.addedDocs spread (documentstore/index.ts:1841) — each outer batch spread inner results into a growing array. Another ~475MB.
  3. totalKeys fetch (indexing.ts:350) — loaded every record manager key into memory just to count them.

Changes

  • Cap addedDocs to 4 preview samples instead of accumulating all docs
  • Remove addedDocs spread in worker thread (field is omitted from persisted result anyway)
  • Replace listKeys({}).length with computed count

Expected Impact

Memory during 95k upsert: ~2GB OOM → ~100-200MB steady-state.

Also scaled Render to Pro Plus (4GB) as belt-and-suspenders.

Related

…stores

Cap addedDocs to 4 preview samples instead of accumulating all 95k+
documents (~475MB). Remove addedDocs spread in worker thread that
duplicated the accumulation. Replace totalKeys listKeys() call with
computed count to avoid loading all record manager keys into memory.
@linear

linear Bot commented Mar 17, 2026

Copy link
Copy Markdown

@vercel

vercel Bot commented Mar 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
answerai-docs Building Building Preview Mar 17, 2026 0:49am
the-answerai Building Building Preview Mar 17, 2026 0:49am

Request Review

@maxtechera
maxtechera merged commit 2bdc116 into staging Mar 17, 2026
7 of 8 checks passed
@maxtechera
maxtechera deleted the fix/kumello-68-upsert-oom branch March 17, 2026 00:51
@claude

claude Bot commented Mar 17, 2026

Copy link
Copy Markdown

test comment from review bot

@claude

claude Bot commented Mar 17, 2026

Copy link
Copy Markdown

@/tmp/review.md

@claude

claude Bot commented Mar 17, 2026

Copy link
Copy Markdown

@/home/runner/work/theanswer/theanswer/.claude/pr_review_1031.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant