fix(router): resolve plan cache memory leaks on config reload#3023
fix(router): resolve plan cache memory leaks on config reload#3023dkorittki 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.
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:
|
|
@SkArchon can you take a look at this? |
SkArchon
left a comment
There was a problem hiding this comment.
Tried it locally as well, lgtm
|
Waiting with merge to see if #3035 solves this issue. |
|
Ultimately fixed by #3035. Closing this one. |
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.