Commit c9a18b7
committed
fix(notifier): lazy-GC dead sessions on every fanout / per-peer push
rmcp's ServerHandler doesn't expose a session-close callback and the
streamable-HTTP session manager owns the close path internally, so we
have no obvious place to call unregister_session. Without GC the
sessions map grows unbounded across the gateway's lifetime — every
reconnect leaves stale entries that fanout iterates and the resolver
attempts to re-route.
What rmcp *does* give us is `Peer<R>::is_transport_closed()`, which
flips true once the underlying transport has terminated. Reap lazily:
each fanout / per-peer push snapshots the live session list, scans for
closed peers, and removes them from both `sessions` and the
`feature_set_resolver`'s `SessionRootsRegistry` in one pass. After the
sweep the regular routing loop runs against the cleaned snapshot.
Three call sites covered: get_peers_for_space (broadcasts),
get_peers_for_space_with_streams (the variant used by the per-type
notify_*_list_changed), and notify_peer_lists_changed (per-client
push for resolution flips and grant edits). Logged at info level
when dead > 0 so a future spike is visible.
Adds `FeatureSetResolverService::session_roots()` accessor so the
notifier can keep the two registries in sync — they were drifting
silently otherwise.
cargo check + clippy (-D warnings) clean.
Signed-off-by: Mohammod Al Amin Ashik <maa.ashik00@gmail.com>1 parent f08e8ec commit c9a18b7
2 files changed
Lines changed: 89 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
325 | 371 | | |
326 | 372 | | |
327 | 373 | | |
328 | 374 | | |
329 | 375 | | |
330 | 376 | | |
331 | | - | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
332 | 380 | | |
333 | 381 | | |
334 | 382 | | |
| |||
339 | 387 | | |
340 | 388 | | |
341 | 389 | | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
342 | 400 | | |
343 | 401 | | |
344 | 402 | | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
345 | 406 | | |
346 | 407 | | |
347 | 408 | | |
| |||
811 | 872 | | |
812 | 873 | | |
813 | 874 | | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
814 | 883 | | |
815 | 884 | | |
816 | 885 | | |
817 | 886 | | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
818 | 890 | | |
819 | 891 | | |
820 | 892 | | |
| |||
995 | 1067 | | |
996 | 1068 | | |
997 | 1069 | | |
998 | | - | |
| 1070 | + | |
999 | 1071 | | |
1000 | 1072 | | |
1001 | 1073 | | |
1002 | 1074 | | |
1003 | | - | |
| 1075 | + | |
1004 | 1076 | | |
1005 | 1077 | | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
1006 | 1085 | | |
1007 | 1086 | | |
1008 | 1087 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
121 | 128 | | |
122 | 129 | | |
123 | 130 | | |
| |||
0 commit comments