Commit 2dec1be9 authored by TousakaRin's avatar TousakaRin

fix bug: Isolation cannot be triggered when ema_latency is 0

parent 61096437
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <cmath> #include <cmath>
#include <gflags/gflags.h> #include <gflags/gflags.h>
#include <butil/time.h> #include <butil/time.h>
#include <butil/logging.h>
#include "brpc/circuit_breaker.h" #include "brpc/circuit_breaker.h"
namespace brpc { namespace brpc {
...@@ -116,7 +117,9 @@ int64_t CircuitBreaker::EmaErrorRecorder::UpdateLatency(int64_t latency) { ...@@ -116,7 +117,9 @@ int64_t CircuitBreaker::EmaErrorRecorder::UpdateLatency(int64_t latency) {
bool CircuitBreaker::EmaErrorRecorder::UpdateErrorCost(int64_t error_cost, bool CircuitBreaker::EmaErrorRecorder::UpdateErrorCost(int64_t error_cost,
int64_t ema_latency) { int64_t ema_latency) {
const int max_mutilple = FLAGS_circuit_breaker_max_failed_latency_mutilple; const int max_mutilple = FLAGS_circuit_breaker_max_failed_latency_mutilple;
if (ema_latency != 0) {
error_cost = std::min(ema_latency * max_mutilple, error_cost); error_cost = std::min(ema_latency * max_mutilple, error_cost);
}
//Errorous response //Errorous response
if (error_cost != 0) { if (error_cost != 0) {
int64_t ema_error_cost = int64_t ema_error_cost =
......
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