Unverified Commit a6298c1d authored by Ge Jun's avatar Ge Jun Committed by GitHub

Merge pull request #1005 from TousakaRin/circuit_breaker

ignore ELIMIT for circuit breaker
parents 2fe49c9b e67b3bbd
...@@ -15,10 +15,13 @@ ...@@ -15,10 +15,13 @@
// specific language governing permissions and limitations // specific language governing permissions and limitations
// under the License. // under the License.
#include "brpc/circuit_breaker.h"
#include <cmath> #include <cmath>
#include <gflags/gflags.h> #include <gflags/gflags.h>
#include <butil/time.h>
#include "brpc/circuit_breaker.h" #include "brpc/errno.pb.h"
#include "butil/time.h"
namespace brpc { namespace brpc {
...@@ -57,7 +60,7 @@ namespace { ...@@ -57,7 +60,7 @@ namespace {
#define EPSILON (FLAGS_circuit_breaker_epsilon_value) #define EPSILON (FLAGS_circuit_breaker_epsilon_value)
} // namepace } // namespace
CircuitBreaker::EmaErrorRecorder::EmaErrorRecorder(int window_size, CircuitBreaker::EmaErrorRecorder::EmaErrorRecorder(int window_size,
int max_error_percent) int max_error_percent)
...@@ -172,6 +175,16 @@ CircuitBreaker::CircuitBreaker() ...@@ -172,6 +175,16 @@ CircuitBreaker::CircuitBreaker()
} }
bool CircuitBreaker::OnCallEnd(int error_code, int64_t latency) { bool CircuitBreaker::OnCallEnd(int error_code, int64_t latency) {
// 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 returned ELIMIT.
if (error_code == ELIMIT) {
return true;
}
if (_broken.load(butil::memory_order_relaxed)) { if (_broken.load(butil::memory_order_relaxed)) {
return false; 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