Repository navigation
fix(kv-router): break request-lease observer ownership cycle - #15258
jthomson04 merged 1 commit into
Conversation
|
π Hi surajssd! Thank you for contributing to ai-dynamo/dynamo. Just a reminder: The π |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. π βΉοΈ Recent review infoβοΈ Run configurationConfiguration used: Repository: ai-dynamo/dynamo/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: π Files selected for processing (2)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. WalkthroughThe router now passes a weak-reference-backed replica observer to ChangesReplica Lease Observer
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: βͺ Minimal Β· up to The observer change appears ready to merge after normal checks. π₯ Pre-merge checks | β 4 | β 1β Failed checks (1 warning)
β Passed checks (4 passed)
Comment |
jthomson04
left a comment
There was a problem hiding this comment.
Reviewed the split from #14965. The weak observer breaks the ownership cycle and preserves live callbacks. The change is self-contained. No code findings from source review.
|
/ok to test c6c92af |
The scheduler holds the request-lease manager as its replica observer, and the manager holds the scheduler booking cleanup handle it receives from set_scheduler. Both edges are strong, so neither side can drop once KvRouter construction has wired them, and a router that fails to construct after that point leaks its scheduler and lease state. Hand the scheduler a weak observer instead. Callbacks are forwarded while the manager is alive and become no-ops once it is gone. The regression test admits a booking, drives the three callbacks through the observer, drops the router, and asserts the manager is released. It fails against the strong observer. Signed-off-by: Suraj Deshmukh <surajd.service@gmail.com>
c6c92af to
8737d74
Compare
|
/ok to test 8737d74 |
Overview:
KvRouter::newhands the scheduler a strongArcto theRequestLeaseManageras its replica observer, and the manager holds the scheduler'sSchedulerBookingCleanuphandle that it receives fromset_scheduler. Both edges are strong, so neither side can drop once construction has wired them. A router that fails to construct after that point, or one that is dropped, leaks its scheduler actor and lease state. This PR replaces the strong observer with a weak one so the cycle is broken while callbacks still reach the manager for as long as it is alive.This is the first of three independent PRs split out of #14965. That PR's Mooncake Store test for failed router construction depends on
RequestLeaseManager::replica_observerfrom this change. The leak itself exists onmaintoday and is not specific to Mooncake Store.Details:
RequestLeaseManager::replica_observer, which returns anArc<dyn ReplicaRequestLeaseObserver>backed by aWeak<RequestLeaseManagerInner>.impl ReplicaRequestLeaseObserver for RequestLeaseManagerwith a privateWeakRequestLeaseObserver. Each ofadmitted,progressed, andcompletedupgrades the weak reference and forwards to the existingregister_remote,touch_booking, andcomplete_remotemethods, or becomes a no-op once the manager is gone.KvRouter::newpassesrequest_leases.replica_observer()to the scheduler instead ofSome(Arc::new(request_leases.clone())).replica_observer_forwards_live_callbacks_without_retaining_manager. It admits a booking on a tracked router, drives the three callbacks through the observer and checks the lease record at each step, drops the router, and asserts the manager is released. It then calls the callbacks again on the dangling observer to confirm they are no-ops.tracked_routertest helper inkv_router.rspub(super)so therequest_leasetest module can reuse it.Where should the reviewer start?
lib/llm/src/kv_router/request_lease.rs:replica_observerandWeakRequestLeaseObserver, then the new test at the top of thetestsmodule.lib/llm/src/kv_router.rs: the one-line change inKvRouter::newwhere the observer is handed to the scheduler.Validation
Both tests in the module pass. The regression test was also run against the previous strong observer in a throwaway worktree, where the
manager.upgrade().is_none()assertion fails, so the test does detect the cycle.cargo fmt --all --checkis clean.Related Issues
π This PR is linked to an issue:
Summary by CodeRabbit