fix: release P2C inflight on failover retry upstream #7982
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 304 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.342
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #7982"
general
weight: 0.35
Aias00
What this PR does
Fixes the P2C
inflightleak on the failover retry path.DefaultRetryStrategy.resendre-selects a retry upstream throughLoadbalancerUtils.getForExchange, which increments the P2Cinflightcounter of the newly picked upstream. Divide's completion callback (responseTrigger) only captures the initially selected upstream, so nothing released the retry attempt's increment. Repeated failovers therefore inflatedinflighton retry destinations and distorted subsequent P2C load estimates.This attaches a
doFinallycleanup that decrements the retry upstream'sinflighton success, failure and cancellation, guarded to the P2C algorithm (the only balancer that increments on selection), so every actual P2C attempt keeps paired accounting on its own selected upstream.Related Issue
Fixes #7975
Related: #7974 (PR #7980) — this branch is stacked on the #7974 singleton-selection fix.
Related: #6733 — fixed cancellation cleanup for the original forwarding path; the separate failover path still lacked per-attempt cleanup.
Why stacked on #7980 (#7974)
#7974 makes
P2cLoadBalancer.selectincrementinflighteven for a singleton candidate list. The retry cleanup here must therefore release that increment for both paths:doSelectincrements (the exact scenario in #7975);selectis short-circuited, and #7974 is what adds the increment.Building on #7980 keeps the accounting paired in every case and avoids a negative-count regression that an unguarded decrement would cause if this landed before #7974. Please merge #7980 first — this PR retargets to
masterautomatically afterwards.Type of change
How was this tested
RetryStrategyTest:-
testFailoverReleasesP2cInflightOnMultiCandidateRetry(two candidates after exclusion → P2CdoSelectpath)-
testFailoverReleasesP2cInflightOnSingletonRetry(one candidate after exclusion → short-circuit path, validates the #7974 + #7975 pairing)./mvnw -pl :shenyu-plugin-httpclient -am test -Dtest=RetryStrategyTest→ 26 tests, 0 failures./mvnw checkstyle:check -pl :shenyu-plugin-httpclient→ 0 violationsChecklist