Skip to content

Commit

Permalink
Add memcached server address to Set() error (#2775)
Browse files Browse the repository at this point in the history
* Add memcached server address to Set() error

Signed-off-by: Marco Pracucci <[email protected]>

* Addressed review comments

Signed-off-by: Marco Pracucci <[email protected]>
  • Loading branch information
pracucci authored Jun 18, 2020
1 parent aa60140 commit 2c4697f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/cacheutil/memcached_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (c *memcachedClient) Stop() {
c.workers.Wait()
}

func (c *memcachedClient) SetAsync(ctx context.Context, key string, value []byte, ttl time.Duration) error {
func (c *memcachedClient) SetAsync(_ context.Context, key string, value []byte, ttl time.Duration) error {
// Skip hitting memcached at all if the item is bigger than the max allowed size.
if c.config.MaxItemSize > 0 && uint64(len(value)) > uint64(c.config.MaxItemSize) {
c.skipped.WithLabelValues(opSet, reasonMaxItemSize).Inc()
Expand All @@ -287,7 +287,11 @@ func (c *memcachedClient) SetAsync(ctx context.Context, key string, value []byte
})
if err != nil {
c.failures.WithLabelValues(opSet).Inc()
level.Warn(c.logger).Log("msg", "failed to store item to memcached", "key", key, "sizeBytes", len(value), "err", err)

// If the PickServer will fail for any reason the server address will be nil
// and so missing in the logs. We're OK with that (it's a best effort).
serverAddr, _ := c.selector.PickServer(key)
level.Warn(c.logger).Log("msg", "failed to store item to memcached", "key", key, "sizeBytes", len(value), "server", serverAddr, "err", err)
return
}

Expand Down

0 comments on commit 2c4697f

Please sign in to comment.