Skip to content

Commit

Permalink
Fix carbonserver render race error handling format
Browse files Browse the repository at this point in the history
  • Loading branch information
emadolsky committed Dec 13, 2021
1 parent 27907f4 commit e8e4a89
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions carbonserver/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ func (listener *CarbonserverListener) fetchWithCache(ctx context.Context, logger
item := listener.queryCache.getQueryItem(key, size, 60)
res, ok := item.FetchOrLock()
listener.prometheus.cacheRequest("query", ok)
if !ok {
switch {
case !ok:
logger.Debug("query cache miss")
atomic.AddUint64(&listener.metrics.QueryCacheMiss, 1)

Expand All @@ -314,13 +315,13 @@ func (listener *CarbonserverListener) fetchWithCache(ctx context.Context, logger
} else {
item.StoreAndUnlock(response)
}
} else if res != nil {
case res != nil:
logger.Debug("query cache hit")
atomic.AddUint64(&listener.metrics.QueryCacheHit, 1)

response = res.(fetchResponse)
fromCache = true
} else {
default:
// Whenever there are multiple requests approaching for the same records,
// and the proceeding request gets an error, waiting requests should get an error too.
err = fmt.Errorf("invalid cache record for the request")
Expand Down

0 comments on commit e8e4a89

Please sign in to comment.