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

make sure we can receive at least one request #2106

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/brpc/policy/timeout_concurrency_limiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ bool TimeoutConcurrencyLimiter::OnRequested(int current_concurrency,
if (cntl != nullptr && cntl->timeout_ms() != UNSET_MAGIC_NUM) {
timeout_ms = cntl->timeout_ms();
}
return current_concurrency <= FLAGS_timeout_cl_max_concurrency &&
_avg_latency_us < timeout_ms * 1000;
// In extreme cases, the average latency may be greater than requested
// timeout, allow currency_concurrency is 1 ensures the average latency can
// be obtained renew.
return current_concurrency == 1 ||
yanglimingcn marked this conversation as resolved.
Show resolved Hide resolved
(current_concurrency <= FLAGS_timeout_cl_max_concurrency &&
_avg_latency_us < timeout_ms * 1000);
}

void TimeoutConcurrencyLimiter::OnResponded(int error_code,
Expand Down Expand Up @@ -137,7 +141,7 @@ bool TimeoutConcurrencyLimiter::AddSample(int error_code, int64_t latency_us,
UpdateAvgLatency();
} else {
// All request failed
AdjustAvgLatency(_avg_latency_us / 2);
AdjustAvgLatency(_avg_latency_us * 2);
}
ResetSampleWindow(sampling_time_us);
return true;
Expand Down