Commit 06b2175e authored by helei's avatar helei

ignore ELIMIT

parent cb46bd01
......@@ -32,9 +32,12 @@
namespace brpc {
<<<<<<< HEAD
DEFINE_string(circuit_breaker_ignored_error_codes, "2004",
"Comma sparated error code list, those error codes will be ignored by"
"circuit breaker. Note that you should never ignore 0, we ignored ELIMIT for default.");
=======
>>>>>>> ignore ELIMIT
DEFINE_int32(circuit_breaker_short_window_size, 1500,
"Short window sample size.");
DEFINE_int32(circuit_breaker_long_window_size, 3000,
......@@ -70,32 +73,6 @@ namespace {
#define EPSILON (FLAGS_circuit_breaker_epsilon_value)
static pthread_once_t g_init_ignored_error_codes_once;
std::set<int>* g_ignored_error_codes;
void InitIgnoredErrorCodes() {
g_ignored_error_codes = new std::set<int>;
std::vector<std::string> error_codes;
butil::SplitString(FLAGS_circuit_breaker_ignored_error_codes, ',', &error_codes);
for (const std::string& str : error_codes) {
int error_code = 0;
if (!butil::StringToInt(str, &error_code) || error_code == 0) {
LOG(ERROR) << "Invalid error code '" << str
<< "', check the value of flag 'circuit_breaker_ignored_error_code': "
<< FLAGS_circuit_breaker_ignored_error_codes;
continue;
}
g_ignored_error_codes->insert(error_code);
}
}
const std::set<int>* GetOrNewIgnoredErrorCodes() {
::pthread_once(&g_init_ignored_error_codes_once, InitIgnoredErrorCodes);
return g_ignored_error_codes;
}
} // namepace
CircuitBreaker::EmaErrorRecorder::EmaErrorRecorder(int window_size,
int max_error_percent)
: _window_size(window_size)
......@@ -209,6 +186,7 @@ CircuitBreaker::CircuitBreaker()
}
bool CircuitBreaker::OnCallEnd(int error_code, int64_t latency) {
<<<<<<< HEAD
<<<<<<< HEAD
std::call_once(g_init_ignored_error_codes_once, InitIgnoredErrorCodes);
if (g_ignored_error_codes.find(error_code) != g_ignored_error_codes.end()) {
......@@ -217,6 +195,17 @@ bool CircuitBreaker::OnCallEnd(int error_code, int64_t latency) {
if (ignored_error_codes->find(error_code) != ignored_error_codes->end()) {
>>>>>>> use pthread_once to initialize ignored_error_codes for cb
return true;
=======
// If the server has reached its maximum concurrency, it will return
// ELIMIT directly when a new request arrives. This usually means that
// the entire downstream cluster is overloaded. If we isolate nodes at
// this time, may increase the pressure on downstream. On the other hand,
// since the latency corresponding to ELIMIT is usually very small, we
// cannot handle it as a successful request.Here we simply ignore the requests
// that returns ELIMIT.
if (error_code == ELIMIT) {
return true;
>>>>>>> ignore ELIMIT
}
if (_broken.load(butil::memory_order_relaxed)) {
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment