Skip to content

Commit

Permalink
Turn memcached circuit-breaker on by default (grafana#3189)
Browse files Browse the repository at this point in the history
* Turn memcached circuit-breaker on by default

Will trip after 10 failures within 10 seconds

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Change circuit-breaker log fields to avoid clash

The names 'from' and 'to' are used elsewhere as dates, so avoid re-using them here as strings

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Update CHANGELOG

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Updated doc

Signed-off-by: Marco Pracucci <marco@pracucci.com>

Co-authored-by: Marco Pracucci <marco@pracucci.com>
  • Loading branch information
bboreham and pracucci authored Sep 16, 2020
1 parent 8cbf91f commit 7afdc01
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cache/memcached_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (cfg *MemcachedClientConfig) RegisterFlagsWithPrefix(prefix, description st
f.DurationVar(&cfg.Timeout, prefix+"memcached.timeout", 100*time.Millisecond, description+"Maximum time to wait before giving up on memcached requests.")
f.DurationVar(&cfg.UpdateInterval, prefix+"memcached.update-interval", 1*time.Minute, description+"Period with which to poll DNS for memcache servers.")
f.BoolVar(&cfg.ConsistentHash, prefix+"memcached.consistent-hash", true, description+"Use consistent hashing to distribute to memcache servers.")
f.UintVar(&cfg.CBFailures, prefix+"memcached.circuit-breaker-consecutive-failures", 0, description+"Trip circuit-breaker after this number of consecutive dial failures (if zero then circuit-breaker is disabled).")
f.UintVar(&cfg.CBFailures, prefix+"memcached.circuit-breaker-consecutive-failures", 10, description+"Trip circuit-breaker after this number of consecutive dial failures (if zero then circuit-breaker is disabled).")
f.DurationVar(&cfg.CBTimeout, prefix+"memcached.circuit-breaker-timeout", 10*time.Second, description+"Duration circuit-breaker remains open after tripping (if zero then 60 seconds is used).")
f.DurationVar(&cfg.CBInterval, prefix+"memcached.circuit-breaker-interval", 10*time.Second, description+"Reset circuit-breaker counts after this long (if zero then never reset).")
}
Expand Down Expand Up @@ -147,7 +147,7 @@ func NewMemcachedClient(cfg MemcachedClientConfig, name string, r prometheus.Reg
}

func (c *memcachedClient) circuitBreakerStateChange(name string, from gobreaker.State, to gobreaker.State) {
level.Info(c.logger).Log("msg", "circuit-breaker state change", "name", name, "from", from, "to", to)
level.Info(c.logger).Log("msg", "circuit-breaker state change", "name", name, "from-state", from, "to-state", to)
}

func (c *memcachedClient) dialViaCircuitBreaker(network, address string, timeout time.Duration) (net.Conn, error) {
Expand Down

0 comments on commit 7afdc01

Please sign in to comment.