fix(router): resolve plan cache memory leaks on config reload#3023
Open
dkorittki wants to merge 6 commits into
Open
fix(router): resolve plan cache memory leaks on config reload#3023dkorittki wants to merge 6 commits into
dkorittki wants to merge 6 commits into
Conversation
… values After Close(), cached entries in the sync.Map could keep references to stored values (including query plans holding schema AST pointers) until the Cache struct itself was collected. Clear entries when shutting down the cache so config reload can release the previous graph generation.
Ristretto Close() clears all plan cache entries and fires OnEvict for each one, migrating them into slowplancache right before both caches are torn down. Disable OnEvict during intentional mux shutdown and wait for pending slow-cache writes first.
planWithMetaData stored schemaDocument (full router schema AST, ~200MB) in every cached plan entry but never read it. Drop the field so plan caches do not retain the old schema generation after config reload.
Contributor
WalkthroughThe PR updates planner metadata, changes slow-plan-cache shutdown to drop stored entries and reset bookkeeping, and adds a shutdown gate around plan-cache eviction handling in the router. ChangesPlan cache lifecycle and planner metadata
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
Router-nonroot image scan passed✅ No security vulnerabilities found in image: |
Router image scan passed✅ No security vulnerabilities found in image: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3023 +/- ##
===========================================
+ Coverage 46.53% 61.42% +14.88%
===========================================
Files 1120 259 -861
Lines 154966 30055 -124911
Branches 10060 0 -10060
===========================================
- Hits 72107 18460 -53647
+ Misses 81025 10107 -70918
+ Partials 1834 1488 -346
🚀 New features to boost your workflow:
|
This was referenced Jun 26, 2026
Contributor
Author
|
@SkArchon can you take a look at this? |
SkArchon
approved these changes
Jun 30, 2026
SkArchon
left a comment
Contributor
There was a problem hiding this comment.
Tried it locally as well, lgtm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Combines #3006, #3007, and #3009 with the following additional changes:
#3008 currently not included here, needs some more work. Will be merged separetely.
Summary by CodeRabbit
Checklist
Open Source AI Manifesto
This project follows the principles of the Open Source AI Manifesto. Please ensure your contribution aligns with its principles.