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

add retry limit for excluded backoff type to avoid infinite retry #1002

Merged
merged 2 commits into from
Oct 18, 2023

Conversation

cfzjywxk
Copy link
Contributor

Ref: #1001

Try to add retry limit for excluded backoff type to avoid infinite retry.

@cfzjywxk cfzjywxk requested review from zyguan, you06 and ekexium October 11, 2023 07:25
@cfzjywxk
Copy link
Contributor Author

/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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@@ -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",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.
Copy link
Contributor

@jackysp jackysp Oct 11, 2023

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. 😅

Copy link
Contributor Author

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.

@cfzjywxk cfzjywxk force-pushed the add_excluded_type_limit branch from 7caa1fe to 74d25c5 Compare October 18, 2023 03:12
@cfzjywxk cfzjywxk merged commit 888cbb2 into tikv:master Oct 18, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants