-
Notifications
You must be signed in to change notification settings - Fork 225
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
add retry limit for excluded backoff type to avoid infinite retry #1002
Conversation
/cc @crazycs520 |
maxBackoffTimeExceeded := (b.totalSleep - b.excludedSleep) >= b.maxSleep | ||
maxExcludedTimeExceeded := false | ||
if maxLimit, ok := isSleepExcluded[cfg.name]; ok { | ||
maxExcludedTimeExceeded = b.excludedSleep >= maxLimit && b.excludedSleep >= b.maxSleep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the name maxLimit
, I would suppose the latter part is not necessary. In practice it won't make big difference though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In normal circumstances, this check at the end is not necessary. It's mainly to guard against some erroneous inputs or configurations.
internal/retry/backoff.go
Outdated
@@ -163,7 +169,8 @@ func (b *Backoffer) BackoffWithCfgAndMaxSleep(cfg *Config, maxSleepMs int, err e | |||
backoffDetail.WriteString(":") | |||
backoffDetail.WriteString(strconv.Itoa(times)) | |||
} | |||
errMsg += fmt.Sprintf("\ntotal-backoff-times: %v, backoff-detail: %v", totalTimes, backoffDetail.String()) | |||
errMsg += fmt.Sprintf("\ntotal-backoff-times: %v, backoff-detail: %v, maxBackoffTimeExceeded: %v, maxBackoffTimeExceeded: %v", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errMsg += fmt.Sprintf("\ntotal-backoff-times: %v, backoff-detail: %v, maxBackoffTimeExceeded: %v, maxBackoffTimeExceeded: %v", | |
errMsg += fmt.Sprintf("\ntotal-backoff-times: %v, backoff-detail: %v, maxBackoffTimeExceeded: %v, maxExcludedTimeExceeded: %v", |
var isSleepExcluded = map[string]struct{}{ | ||
BoTiKVServerBusy.name: {}, | ||
var isSleepExcluded = map[string]int{ | ||
BoTiKVServerBusy.name: 600000, // The max excluded limit is 10min. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit too far to add a new limit of it, I'm afraid that someday it will be required to be configurable. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could only be used in some extreme cases like the service is unavailable but the leader is still valid.
Signed-off-by: cfzjywxk <[email protected]>
Signed-off-by: cfzjywxk <[email protected]>
7caa1fe
to
74d25c5
Compare
Ref: #1001
Try to add retry limit for excluded backoff type to avoid infinite retry.