Repository navigation
Bound vmcp health and session registry growth - #6667
lorenzozanee wants to merge 1 commit into
Conversation
|
Sorry for the slow response on this one, @lorenzozanee, and thanks for the work here. We're going to close this PR, though. #5860 is assigned to @RaviTharuma, and the discussion there settled on a different fix: a sweep that reclaims session cache entries once their stored metadata has expired, without renewing the TTL. This PR bounds the health tombstones and the resync registry instead, and as @alex-feel noted on the issue, that isn't expected to change the memory growth reported there. It also says Our contributing guide asks contributors to comment on an issue, wait to be assigned, and follow the approach agreed there before opening a PR. If you think the tombstone and registry bounds are worth fixing on their own, please open a separate issue describing what you've seen, and we can take it from there. Thanks again. |
Summary
All VirtualMCPServer instances grow 2-3x RSS over ~24h, scaling with backend count (12/13/14/19 backends grew 2.0-3.1x vs flat control proxies). Investigation shows two unbounded in-memory maps:
health.statusTracker.removedBackendskept a tombstone per removed backend forever to avoid in-flight health-check races. Under ID churn it grew linearly without expiry.server.healthResyncRegistrykept a per-sessionlistChangedResyncWorker(holding ClientSession + identity) for sessions that ended via TTL expiry. Pruning only happened on the next async resync, so the registry stayed larger than the live session set between health-change events.What changed:
removedBackendswith a TTL of2*checkInterval(default 60s, 5m fallback). Entries expire lazily onisRemovedand are pruned periodically inUpdateBackendsandperformHealthCheck, and proactively atRemoveBackendinsertion.snapshotnow returns a map,resyncSessionsOnBackendHealthChangechecksGetMultiSessionfor each entry and removes dead sessions before triggering, keeping|workers| == |liveSessions|.Fixes #5860
Type of change
Test plan
task test)task test-e2e)task lint-fix)New regression tests:
pkg/vmcp/server/regression_5860_health_resync_test.go: verifies fan-out prunes dead sessions and only triggers live sessions (fails on base with 4 workers vs 2 live).pkg/vmcp/health/regression_5860_tombstone_test.go: churns 50 distinct backends and asserts tombstones are bounded after TTL (fails on base with 50 entries).Existing
pkg/vmcp/healthandpkg/vmcp/serversuites pass (task testwith-race).API Compatibility
v1beta1API, OR theapi-break-allowedlabel is applied and the migration guidance is described above.Changes
pkg/vmcp/health/status.gomap[string]bool->map[string]time.Timewith TTL, lazy and periodic prunepkg/vmcp/health/monitor.gocheckInterval, prune inUpdateBackends/performHealthCheckpkg/vmcp/server/serve_health_resync.gosnapshotmap, synchronousGetMultiSessionfilter at fan-outpkg/vmcp/server/serve_health_resync_test.gopkg/vmcp/health/regression_5860_tombstone_test.gopkg/vmcp/server/regression_5860_health_resync_test.goSupersedes #6450 (原PR分支已删,按原提交重建)