fix(router): config reload memory leak — graphMux nil + proto reset - #3
Merged
arutkowski00 merged 13 commits intoJun 25, 2026
Merged
Conversation
Stop storing schemaDocument in cached planWithMetaData entries so plan caches no longer pin the old router schema AST (~200MB) after CDN reloads. Also call OnRouterConfigReload before building a new graph server so slow-plan cache entries are extracted while the old graphMux is still referenced, matching the supervisor restart path. Co-authored-by: Cursor <cursoragent@cursor.com>
Disable ristretto OnEvict migration into slowplancache when a graphMux is shutting down, since Close() clears every entry and the fallback cache is about to be closed anyway. Close websocket subscriptions synchronously before plan caches so preparedPlan and executor refs are released first. Co-authored-by: Cursor <cursoragent@cursor.com>
Expose /debug/pprof/heap and related routes on the pprof server so forced-GC heap snapshots (heap?gc=1) work for memory leak diagnosis. Co-authored-by: Cursor <cursoragent@cursor.com>
Flag defaults are captured at package init before embedders set PPROF_ADDR in main(), so platform-api ensurePprofAddr had no effect. Re-read env after flag.Parse() matches the existing CONFIG_PATH pattern. Co-authored-by: Cursor <cursoragent@cursor.com>
…head on reload Executor.Close() nils federation schema AST held after graph mux shutdown. Share one upstream subscription client across subgraph factories and disable upstream ping loops when client WebSocket is disabled. Co-authored-by: Cursor <cursoragent@cursor.com>
… unused Skip WSTransport/SSE initialization when the router schema has no subscription root fields or when client WebSocket and pubsub events are both disabled. Co-authored-by: Cursor <cursoragent@cursor.com>
Close and drop Ristretto cache pointers, wsHandler, and mux after graphMux shutdown, and remove shut-down muxes from graphMuxList. Local benchmark: ~74 MB/reload → ~12 MB/reload retained inuse (same-content manifest reloads). Co-authored-by: Cursor <cursoragent@cursor.com>
…ion config Hash mapper.json before re-assembling; skip reload when content is unchanged (mtime-only touches). After a successful reload, swap staticExecutionConfig and proto.Reset the previous config so decoded protojson strings can be collected.
…n refs Pass Changes/Hashes from mapper.json graph hashes on the manifest watcher path so unchanged base or feature-flag muxes survive config reloads. Nil graphServer and graphMux metric fields after shutdown to drop retained references sooner.
… shutdown refs" This reverts commit 2c32b45.
Router-nonroot image scan failed❌ Security vulnerabilities found in image: Please check the security vulnerabilities found in the PR. If you believe this is a false positive, please add the vulnerability to the |
budziam
approved these changes
Jun 25, 2026
Remove late env re-read for PPROF/PYROSCOPE in main.go and extra pprof handlers in profile.go so this PR stays focused on config reload fixes.
Centralize all monday.com config-reload leak fixes in mondaytweaks.go so they are easy to audit and disable individually. Restore profiling helpers from stash behind separate tweak flags.
Remove PPROF/PYROSCOPE env re-read, heap pprof routes, and Pyroscope name/tag helpers so the PR stays focused on config reload memory fixes.
3 tasks
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.
Summary
d2d20a910): Close and nil Ristretto plan/operation caches on shut-downgraphMux; nilwsHandler/mux; remove fromgraphMuxList. Local mirror: ~74 → ~12 MB inuse/reload.3b6aadb27): SHA-256 skip whenmapper.jsonunchanged;proto.Reset(old)after swappingstaticExecutionConfig. Local mirror: ~12 → ~flat MB/reload.73fc25d68): Manifest Changes/Hashes mux reuse did not improve base-hash reload benchmark.Builds on Rounds 1–6 already on this branch (
84f798f92…d80b9add6).Test plan
feature/adamru/fix-config-reload-memory-leak)AddTypeflat, target <<96 Mi/reload (Round 6 baseline)Wiki:
projects/2026-06-24-cosmo-router-memory-leak-investigation.md