@@ -217,7 +217,7 @@ func (c *Store) getMetricNameChunks(ctx context.Context, from, through model.Tim
217
217
level .Warn (logger ).Log ("msg" , "error fetching from cache" , "err" , err )
218
218
}
219
219
220
- fromCache , missing , err := ProcessCacheResponse (chunks , cacheHits , cacheBufs )
220
+ fromCache , missing , err := ProcessCacheResponse (filtered , cacheHits , cacheBufs )
221
221
if err != nil {
222
222
level .Warn (logger ).Log ("msg" , "error fetching from cache" , "err" , err )
223
223
}
@@ -253,17 +253,20 @@ outer:
253
253
return filteredChunks , nil
254
254
}
255
255
256
+ // ProcessCacheResponse decodes the chunks coming back from the cache, separating
257
+ // hits and misses.
256
258
func ProcessCacheResponse (chunks []Chunk , keys []string , bufs [][]byte ) (found []Chunk , missing []Chunk , err error ) {
257
259
ctx := NewDecodeContext ()
258
260
259
- for i , j := 0 , 0 ; i < len (chunks ) && j < len (keys ); {
261
+ i , j := 0 , 0
262
+ for i < len (chunks ) && j < len (keys ) {
260
263
chunkKey := chunks [i ].ExternalKey ()
261
264
262
265
if chunkKey < keys [j ] {
263
266
missing = append (missing , chunks [i ])
264
267
i ++
265
268
} else if chunkKey > keys [j ] {
266
- // Got a chunk response we shouldn 't have
269
+ level . Debug ( util . Logger ). Log ( "msg" , "got chunk from cache we didn 't ask for" )
267
270
j ++
268
271
} else {
269
272
chunk := chunks [i ]
@@ -277,6 +280,10 @@ func ProcessCacheResponse(chunks []Chunk, keys []string, bufs [][]byte) (found [
277
280
}
278
281
}
279
282
283
+ for ; i < len (chunks ); i ++ {
284
+ missing = append (missing , chunks [i ])
285
+ }
286
+
280
287
return
281
288
}
282
289
0 commit comments