Aias00 opened a new issue, #6544:
URL: https://github.com/apache/shenyu/issues/6544

   ## Description
   `private Long beginTime;` is a plain instance field on the `DividePlugin` 
singleton bean. In the `SHORTEST_RESPONSE` branch it is set per-request 
(`beginTime = System.currentTimeMillis()`) and later read in 
`successResponseTrigger` 
(`upstream.getSucceededElapsed().addAndGet(System.currentTimeMillis() - 
beginTime)`). With concurrent requests, request B overwrites `beginTime` while 
request A is still in flight, so A's completion computes `now - <B's start 
time>` — a wrong (often negative or far too small) elapsed value that is 
*added* to the upstream's cumulative `succeededElapsed` counter.
   
   ## Location
   ```
   shenyu-plugin-divide/.../DividePlugin.java:63 (field), 137 (write), 197 
(read in successResponseTrigger)
   ```
   
   ## Impact
   With two or more concurrent HTTP requests matching a divide rule whose 
`loadBalance` is `shortestResponse`, `ShortestResponseLoadBalancer.doSelect` 
picks upstreams by `succeededAverageElapsed * inflight`; corrupted averages 
produce wrong "shortest" selections — traffic is steered to the wrong upstream. 
The corruption is cumulative (`addAndGet` of bad deltas), so it persists and 
worsens.
   
   ## Suggested fix
   Do not store the start time on the singleton. Capture `start` as a local 
`final long` and use `chain.execute(exchange).doOnSuccess(e -> 
successResponseTrigger(upstream, start))`, or stash it in an exchange attribute.
   
   ## Related existing issue(s)
   #6427 (closed) was about P2C EWMA decay order reversal; this is a different 
latency-bookkeeping race in `DividePlugin` itself, distinct.
   
   _Identified during the 2026-08-02 audit; full list in 
[`docs/issue-candidates-2026-08-02.md`](docs/issue-candidates-2026-08-02.md)._


-- 
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