← Back to Pull requests

fix: release P2C inflight on failover retry upstream #7982

Closed
unknown closed this pull request without merging on Oct 23, 2026 03:16 UTC
View on GitHub
unknown unknown commented on Oct 22, 2026 07:39 UTC
Author

What this PR does

Fixes the P2C inflight leak on the failover retry path.

DefaultRetryStrategy.resend re-selects a retry upstream through LoadbalancerUtils.getForExchange, which increments the P2C inflight counter 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 inflated inflight on retry destinations and distorted subsequent P2C load estimates.

This attaches a doFinally cleanup that decrements the retry upstream's inflight on 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.select increment inflight even for a singleton candidate list. The retry cleanup here must therefore release that increment for both paths:

  • multi-candidate retry → P2C doSelect increments (the exact scenario in #7975);

  • singleton retry (one candidate left after exclusion) → select is 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 master automatically afterwards.

    Type of change

  • Bug fix
  • How was this tested

  • Unit tests added — RetryStrategyTest:

  • - testFailoverReleasesP2cInflightOnMultiCandidateRetry (two candidates after exclusion → P2C doSelect path)
    - 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 violations
  • Checklist

  • No new source files (license header N/A)

  • No breaking changes to public API / config / DB schema
  • Diff: 304 lines (+228 / -76) across 3 files Reviewer: Aias00 Review duration: 1176m
    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
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.1% (MEDIUM) · Higher = larger blast radius
    40.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.9% · Safe to merge
    15.9%
    Repository