From e6c76ef7218358530ef9cd84139592665c7d6e59 Mon Sep 17 00:00:00 2001 From: Yuewei Na Date: Mon, 10 Aug 2026 11:29:11 -0700 Subject: [PATCH] fix(kv-router): stamp request identity on decode-affinity scoring row The decode-affinity branch in `DefaultWorkerScorer::worker_logit` emits its own candidate scoring row and returns early, so it never reaches the two rows that carry `request_id` and `worker_type`. #12370 stamped those two rows; #11720 added this third row in parallel and merged without the fields, so any decision taking this branch emits candidates in the pre-#12370 shape. The predicate keys off the configured `overlap_score_credit` (default 1.0) rather than any measured overlap, so on an affected deployment every decision takes the branch and every candidate row loses its identity. Grouping the candidates of one routing decision then falls back to line adjacency, which is unreliable when decisions interleave. Add the two fields so all three candidate rows share one shape. Both values are already in scope in this branch and are evaluated inside the macro, so they cost nothing when DEBUG is disabled. Observability only: routing behaviour, metrics and API surfaces are unchanged, and these rows are DEBUG-level. Signed-off-by: Yuewei Na --- lib/kv-router/src/scheduling/selector/default.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/kv-router/src/scheduling/selector/default.rs b/lib/kv-router/src/scheduling/selector/default.rs index 75e96919c93c..4f9175b117a0 100644 --- a/lib/kv-router/src/scheduling/selector/default.rs +++ b/lib/kv-router/src/scheduling/selector/default.rs @@ -266,7 +266,12 @@ impl> DefaultWorkerScorer { let overlap_adjusted_decode_blocks = (decode_cost_blocks - overlap_credit_blocks).max(0.0); let logit = overlap_adjusted_decode_blocks + active_request_cost_blocks; + // Stamped for the same reason as the two rows below: this row is emitted from the + // `SchedulerQueueActor` task, so the logging layer cannot attach request identity to + // it, and this branch returns early without reaching them. tracing::debug!( + request_id = context.request_id, + worker_type = self.worker_type, "{formula_name} for worker_id={} dp_rank={:?} with {effective_overlap_blocks:.2} effective cached blocks: {logit:.3} \ = max(0, decode_blocks - overlap_credit_blocks) + active_request_cost_blocks \ = max(0, {decode_cost_blocks:.3} - {overlap_credit_blocks:.3}) + {active_request_cost_blocks:.3}",