Skip to content

fix(consolidation): release large objects between retry attempts to prevent RSS leak (#2273)#2795

Open
handnewb wants to merge 1 commit into
vectorize-io:mainfrom
handnewb:fix/consolidation-rss-leak
Open

fix(consolidation): release large objects between retry attempts to prevent RSS leak (#2273)#2795
handnewb wants to merge 1 commit into
vectorize-io:mainfrom
handnewb:fix/consolidation-rss-leak

Conversation

@handnewb

Copy link
Copy Markdown
Contributor

Summary

When a consolidation LLM call fails repeatedly, the call_kwargs dict (containing the full system_prompt and user_content strings — potentially hundreds of KB of text) and the response object were kept in scope across the retry loop. With consolidation_max_attempts=5 and retry storms, repeated failures could accumulate hundreds of MB of unreclaimable memory, eventually causing OOM.

Changes

  • Initialize call_kwargs and response as None before the retry loop
  • Add finally block with explicit del to release references between retry attempts
  • Use try/except NameError guards for safety (the variables may not be assigned if the exception occurs before their assignment line, though in practice this never happens)

Verification

  • Successful consolidation path is unchanged (objects are naturally cleaned up on return)
  • Failed retry path now releases references before the next attempt
  • No functional change to consolidation logic

Closes #2273

…revent RSS leak

When a consolidation LLM call fails repeatedly, the call_kwargs dict
(containing the full system_prompt and user_content strings — potentially
hundreds of KB of text) and the response object were kept in scope
across the retry loop. With consolidation_max_attempts=5, repeated
failures could accumulate hundreds of MB of unreclaimable memory.

This adds explicit cleanup in a finally block between retry attempts.

Closes vectorize-io#2273
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.

consolidation failure path leaks LLM context — RSS grows unboundedly on retry storms

1 participant