fix(router): clear slowplancache entries on Close#3006
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughCache.Close() now clears stored entries after shutting down the writer and resets the tracked size. A new unit test closes a populated cache and checks that the entries map is empty and size is zero. ChangesSlow plan cache close cleanup
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3006 +/- ##
==========================================
- Coverage 60.27% 54.08% -6.20%
==========================================
Files 477 243 -234
Lines 62471 29469 -33002
Branches 6131 0 -6131
==========================================
- Hits 37656 15939 -21717
+ Misses 24787 11947 -12840
- Partials 28 1583 +1555
🚀 New features to boost your workflow:
|
|
Closing this PR because this is now handled in #3023 |
Problem
After
slowplancache.Close(), entries remained in the underlyingsync.Map, keeping references to cached query plans (and any schema pointers they hold) until the Cache struct was garbage-collected.Fix
Clear all entries and reset the size counter when
Close()runs.Test plan
TestCache_CloseReleasesEntriesgo test ./router/pkg/slowplancache/...Part of config hot-reload memory leak investigation (monday.com #3221).
Summary by CodeRabbit
Bug Fixes
Tests