SURYAS1306 opened a new pull request, #16048:
URL: https://github.com/apache/dubbo/pull/16048
## What is the purpose of the change?
This PR fixes an issue in AdaptiveLoadBalance / AdaptiveMetrics where
latency decay behaves incorrectly when provider metrics are not updated for a
period of time.
Currently, when no new provider metrics arrive, getLoad() may repeatedly
apply the penalty branch or aggressively right-shift lastLatency, which can
result in stale or extreme values dominating EWMA. This makes adaptive load
balancing unstable, especially in low-QPS or intermittent-update scenarios.
This PR ensures that latency decays safely and progressively instead of
collapsing or being stuck at penalty values.
Fixes #15810
## What is changed?
### 1. Improved decay logic in AdaptiveMetrics#getLoad()
- Prevents lastLatency from collapsing to zero.
- Ensures decay happens smoothly when provider metrics are not refreshed.
- Avoids repeatedly applying the penalty path when timestamps are equal.
### 2. Added unit test
Added `testAdaptiveMetricsDecayWithoutProviderUpdate`
Verifies that when provider metrics are not updated:
- latency decays over time
- penalty value is not stuck
- EWMA continues to evolve
## Why is this needed?
Adaptive load balancing relies on EWMA latency to reflect recent performance
trends.
Without this fix:
- old latency values can dominate indefinitely
- penalty values may be repeatedly re-applied
- low-traffic services become unfairly weighted
This change makes adaptive load balancing more stable, realistic, and robust
under real-world traffic patterns.
## Verifying this change
- Added new unit test covering the decay scenario
- All tests pass locally:
```bash
mvn -pl dubbo-cluster -am test
```
## Checklist
- [x] Related GitHub issue referenced (Fixes #15810)
- [x] Logic change explained clearly
- [x] Unit test added
- [x] All tests passing locally
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]