[BUG] ResponseTimeCircuitBreaker#slidingCounter is actually a 'rollingCounter' and cause unexpected degrade.
- Dominant language
- Java
- Stars
- 23.1k
- Forks
- 8.1k
- PR merge metrics
- No merged PRs in 30d
Description
`public ResponseTimeCircuitBreaker(DegradeRule rule) {
this(rule, new SlowRequestLeapArray(1, rule.getStatIntervalMs()));
}`
The sampleCount of SlowRequestLeapArray is set to 1, this means the count number will be reset to **zero** when a new statistic window begins and makes it not really a **sliding** counter.
The problem is, when I mean to degrade when 100% of RTs exceed 5ms in 1 seconds( minRequestAmount is set to 1 ), in this case only one slow request can cause the resource degrade. Though a larger minRequestAmount mitigates this issue, but the proper number is not easy to estimate 'cause the QPS is changing.
So I suggest to set the sampleCount to at least 2.
`public ResponseTimeCircuitBreaker(DegradeRule rule) {
this(rule, new SlowRequestLeapArray(**2,** rule.getStatIntervalMs()));
}`
Contributor guide
Research direction
Start with the ResponseTimeCircuitBreaker constructor and its SlowRequestLeapArray configuration. Check how the one-second statistic window resets the count, then verify the proposed sample-count behavior with a focused regression test; done means slow requests are evaluated across sliding windows without an unintended reset to zero.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100