dmsolr opened a new pull request, #7982:
URL: https://github.com/apache/shenyu/pull/7982

   ## 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
   
   - [x] Bug fix
   
   ## How was this tested
   
   - [x] 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)
   - [x] `./mvnw -pl :shenyu-plugin-httpclient -am test 
-Dtest=RetryStrategyTest` → 26 tests, 0 failures
   - [x] `./mvnw checkstyle:check -pl :shenyu-plugin-httpclient` → 0 violations
   
   ## Checklist
   
   - [x] No new source files (license header N/A)
   - [x] No breaking changes to public API / config / DB schema
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to