Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug in circuit_breaker.go about SlowRequestRatio #315

Merged
merged 6 commits into from
Nov 5, 2020
Merged

fix bug in circuit_breaker.go about SlowRequestRatio #315

merged 6 commits into from
Nov 5, 2020

Conversation

JayiceZ
Copy link
Contributor

@JayiceZ JayiceZ commented Nov 2, 2020

Describe what this PR does / why we need it

when slowRequestRatio was set to 1.0d, requests will never be blocked. Because the currentRatio will never be bigger than 100%

Does this pull request fix one issue?

Describe how you did it

Special treatment for case when slowRequestRatio was set to 1.0d

Describe how to verify it

Special notes for reviews

@CLAassistant
Copy link

CLAassistant commented Nov 2, 2020

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@binbin0325 binbin0325 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the same problem exists in errorRatioCircuitBreaker

@JayiceZ
Copy link
Contributor Author

JayiceZ commented Nov 3, 2020

Maybe the same problem exists in errorRatioCircuitBreaker

Exactly. Thanks for your tip

@louyuting
Copy link
Collaborator

The Rule.Threshold means the max value that circuit breaker allowed. If the statistic ratio is great than Threshold, the circuit breaker will open.

From my perspective, setting Rule.Threshold as 1.0 doesn't make sense. May be we should check (Threshold==1.0) in

func IsValid(r *Rule) error {

@louyuting louyuting added the kind/enhancement Category issues or PRs related to enhancement label Nov 3, 2020
@louyuting louyuting self-requested a review November 3, 2020 12:58
@JayiceZ
Copy link
Contributor Author

JayiceZ commented Nov 3, 2020

The Rule.Threshold means the max value that circuit breaker allowed. If the statistic ratio is great than Threshold, the circuit breaker will open.

From my perspective, setting Rule.Threshold as 1.0 doesn't make sense. May be we should check (Threshold==1.0) in

func IsValid(r *Rule) error {

You make a good point! But I think it would be better to support this, in case this feature is needed in some scenarios? What do you think?

@@ -290,7 +290,8 @@ func (b *slowRtCircuitBreaker) OnRequestComplete(rt uint64, err error) {
return
}

if slowRatio > b.maxSlowRequestRatio {
// Special case when maxSlowRequestRatio is set to 1.0 should be handled
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we need to change checking logic.
Using "slowRatio >= b.maxSlowRequestRatio"、”errorRatio >= b.errorRatioThreshold“ and ”errorCount >= b.errorCountThreshold“

It's easier to understand.

@louyuting
Copy link
Collaborator

The Rule.Threshold means the max value that circuit breaker allowed. If the statistic ratio is great than Threshold, the circuit breaker will open.
From my perspective, setting Rule.Threshold as 1.0 doesn't make sense. May be we should check (Threshold==1.0) in

func IsValid(r *Rule) error {

You make a good point! But I think it would be better to support this, in case this feature is needed in some scenarios? What do you think?

Maybe we need improve the checking logic here. Refer to my comments

@sczyh30 sczyh30 added the area/circuit-breaking Issues or PRs related to circuit breaking label Nov 4, 2020
@codecov-io
Copy link

codecov-io commented Nov 4, 2020

Codecov Report

Merging #315 into master will not change coverage.
The diff coverage is 0.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #315   +/-   ##
=======================================
  Coverage   50.31%   50.31%           
=======================================
  Files          68       68           
  Lines        3705     3705           
=======================================
  Hits         1864     1864           
  Misses       1580     1580           
  Partials      261      261           
Impacted Files Coverage Δ
core/circuitbreaker/circuit_breaker.go 68.15% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3926f99...b4c57d4. Read the comment docs.

@louyuting
Copy link
Collaborator

Maybe you do a wrong update. Below is my comments:

Maybe we need to change checking logic.
Using "slowRatio >= b.maxSlowRequestRatio"、”errorRatio >= b.errorRatioThreshold“ and ”errorCount >= b.errorCountThreshold“
It's easier to understand.

@JayiceZ
Copy link
Contributor Author

JayiceZ commented Nov 4, 2020

Maybe you do a wrong update. Below is my comments:

Maybe we need to change checking logic.
Using "slowRatio >= b.maxSlowRequestRatio"、”errorRatio >= b.errorRatioThreshold“ and ”errorCount >= b.errorCountThreshold“
It's easier to understand.

Modified.Thanks for suggestions

Copy link
Collaborator

@louyuting louyuting left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work and looking forward more~

@JayiceZ
Copy link
Contributor Author

JayiceZ commented Nov 5, 2020

Nice work and looking forward more~

appreciated for your help

@louyuting louyuting merged commit a196fcf into alibaba:master Nov 5, 2020
@louyuting louyuting added this to the 1.0.0 milestone Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/circuit-breaking Issues or PRs related to circuit breaking kind/enhancement Category issues or PRs related to enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants