fix(runtime): make push router direct dispatch exact - #10429
Conversation
WalkthroughPushRouter routing behavior is refactored to rely on typed failures instead of pre-validation and silent fallback. ChangesPushRouter typed-failure routing
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
|
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
Signed-off-by: Jacky <18255193+kthui@users.noreply.github.com>
b3d2825 to
43ec8ae
Compare
|
🎯 Code Coverage (details) 🔗 Commit SHA: 1c20260 | Docs | Datadog PR Page | Give us feedback! |
PeaBrane
left a comment
There was a problem hiding this comment.
One non-blocking edge case below; fine to defer it as a follow-up TODO.
Signed-off-by: Jacky <18255193+kthui@users.noreply.github.com>
PeaBrane
left a comment
There was a problem hiding this comment.
@kthui I traced this through the runtime error producers and the KV migration/re-dispatch path. My earlier ResourceExhausted comment was broader than the stale-overload race fixed in the latest commit.
I think the original exact-dispatch changes in 43ec8ae are semantically sound and should stay:
direct(instance_id)must honor the upstream-selected worker; transport fallback must not silently change KV-router selection, booking, or DP-rank state.- If that exact target disappears before transport resolution, typed
CannotConnectis correct and migratable. - Resolving transport before checking overload is also correct: stale overload metadata should not mask a genuinely missing target, and any overload check must apply to the final resolved worker.
The part I think should be rolled back or narrowed is the blanket conversion of every unresolved Allow/Within fallback to CannotConnect. free_ids() can be empty because otherwise eligible, live workers are overloaded. That is a capacity failure, not a discovery/transport failure; classifying it as CannotConnect makes a pool-wide exhaustion migratable and can change its HTTP/error semantics. An actual failed lookup—including Deny for a missing exact target or a selected fallback that also disappeared—can remain CannotConnect.
The broader issue is that ResourceExhausted currently represents both a single selected worker being busy and the entire eligible pool being exhausted. The former should permit reselection when policy allows; the latter should remain non-migratable. That needs its own worker-scoped overload classification and should build on #11647's worker-targeted booking/admission cleanup, rather than relabeling overload as CannotConnect.
I opened #12383 to track that separate follow-up. So for this PR: keep exact dispatch, typed missing-target failure, and resolve-before-overload ordering; defer the worker-local versus pool-wide overload split, and avoid typing ambiguous no-fallback capacity cases as CannotConnect.
Signed-off-by: Jacky <18255193+kthui@users.noreply.github.com>
|
Thanks @PeaBrane — confirmed. Current HEAD (
This keeps the PR focused on exact dispatch and correct ordering while deferring worker-local versus pool-wide overload classification to #12383. The targeted |
Summary
Make
PushRouter::direct()an exact-dispatch API. Once a caller supplies aninstance_id, dispatch targets that worker or returns typedCannotConnect; it no longer silently reselects another worker if the selected instance disappears before transport resolution.Transport resolution now also precedes overload checking, so stale overload metadata cannot mask a missing exact target and availability is checked against the final worker selected by transport resolution.
This keeps routing and migration responsibilities separate: routing selects a worker,
direct()honors that selection, and migration may retry after a typed worker-specific failure.Details
direct()to dispatch withTransportFallback::Deny.DynamoError(ErrorType::CannotConnect)when an exact target is no longer discoverable, preserving migration error classification.direct_within(..., None)permits ordinary fallback.direct_within(..., Some(ids))constrains fallback to the supplied worker set.CannotConnectwhen a fallback worker was selected but disappears before its transport lookup completes.free_ids()can be empty due to no discoverable eligible worker, policy exclusion, or pool-wide overload, that branch retains its existing generic error and carries a TODO for fix(migration): distinguish worker-local overload from pool-wide exhaustion #12383.check_workers_available()in both unary/prepared and bidirectional dispatch. The overload check therefore applies to the final resolved worker and returnsResourceExhaustedonly after a worker has been pinned.direct(), so the exact-dispatch contract is enforced in the shared runtime API.This complements #11993: that change allows an already-selected, locally inhibited worker to remain directly dispatchable while it is still discoverable; this change handles the later race where the selected worker disappears before transport resolution.
The broader distinction between worker-local overload and pool-wide capacity exhaustion is intentionally deferred to #12383.
Validation
cargo fmt --manifest-path /workspace/Cargo.toml --all -- --checkcargo test -p dynamo-runtime transport_resolution -- --nocapture(4 passed)cargo test -p dynamo-runtime exact_dispatch -- --nocapture(1 passed)cargo test -p dynamo-runtime --lib(497 passed, 2 ignored)cargo test -p dynamo-runtime direct_dispatch_ignores_local_inhibition -- --nocapturecargo test -p dynamo-llm router_request_counters_follow_admission_and_completion_lifecycle --lib -- --nocapturecargo clippy -p dynamo-runtime --no-deps --all-targets -- -D warningscargo clippy -p dynamo-llm --no-deps --lib -- -D warningspre-commit run --files lib/runtime/src/pipeline/network/egress/push_router.rsReviewer guide
Start with
lib/runtime/src/pipeline/network/egress/push_router.rs, especially:direct()and itsTransportFallback::Denycontract;generate_with_fault_detection_prepared()andbidirectional_dispatch();Deny, selected-fallback lookup failure, and ambiguous no-candidate branches inresolve_transport();transport_resolution_precedes_stale_overload_checkandtransport_resolution_honors_fallback_policy.Related issues