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

   ## What this PR does
   
   Fixes a P2C `inflight` accounting leak on the singleton selection path.
   
   `AbstractLoadBalancer.select` short-circuits a candidate list of size 1 and 
returns the only upstream **without** calling `P2cLoadBalancer.doSelect`, so 
the `inflight.incrementAndGet()` in `doSelect` is skipped. Divide's P2C 
completion callback (`DividePlugin.responseTrigger` via `doFinally`) still 
decrements the selected upstream unconditionally. Repeated singleton requests 
therefore drive `inflight` below its baseline (`1`) and eventually negative, 
and P2C then uses that negative value in `load = lag * inflight`.
   
   This affects single-upstream deployments and any request where candidate 
filtering leaves exactly one eligible upstream. The half-open probe path is 
unaffected (it does its own increment).
   
   The fix overrides `select` in `P2cLoadBalancer` to perform the same 
increment + `lastPicked` update that `doSelect` performs, so start/completion 
accounting stays paired for a singleton list.
   
   ## Related Issue
   
   Fixes #7974
   
   Related: #7975 (failover retry path, separate PR), #6733 (prior 
cancellation-cleanup fix)
   
   ## Type of change
   
   - [x] Bug fix
   - [ ] New feature / enhancement
   - [ ] Refactor (no functional change)
   - [ ] Documentation
   - [ ] Chore / build
   
   ## How was this tested
   
   - [x] Unit tests added: singleton select increments once; the select + 
completion-decrement loop from the issue reproduction stays at baseline and 
never goes negative
   - [x] `./mvnw test -pl shenyu-loadbalancer` passed (70 tests, no regression)
   - [x] `./mvnw checkstyle:check -pl shenyu-loadbalancer` passed (0 violations)
   
   ## Checklist
   
   - [x] Apache 2.0 license header present (no new files)
   - [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