You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] DividePlugin.beginTime is a shared mutable instance field, racy under shortestResponse load balancing #6544
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.
Closing as fixed by #6429. DividePlugin no longer stores beginTime as shared mutable instance state; shortest-response timing now uses a per-request local value.
Activity
github-actions commentedon Aug 2, 2026
👋 Hello @yuluo-yx
A new issue has been opened by @Aias00:
Please review when you have time. Thank you! 🙏
Aias00 commentedon Oct 1, 2026
Closing as fixed by #6429.
DividePluginno longer storesbeginTimeas shared mutable instance state; shortest-response timing now uses a per-request local value.