We check the cache number (incremented by deletes) after executing a
query with the value returned by the queriers which executed it. If
they’re different, we know we can’t safely cache. However, we’re never
actually returning a number from the queriers. This means that as soon
as this cache number is incremented by a delete, it’ll disable the
results cache for that tenant completely.
I suspect this has been a latent bug since we forked cortex (goes back
to missing some code from this
[PR](https://github.com/cortexproject/cortex/pull/2279) into cortex from
@sandeepsukhani back in the day!). It just showed itself once we started
using deletes.
level.Debug(s.logger).Log("msg",fmt.Sprintf("we found results cache gen number %s set in store but none in headers",genNumberFromCtx))
level.Debug(logger).Log("msg",fmt.Sprintf("we found results cache gen number %s set in store but none in headers",genNumberFromCtx))
returnfalse
}
for_,gen:=rangegenNumbersFromResp{
ifgen!=genNumberFromCtx{
level.Debug(s.logger).Log("msg",fmt.Sprintf("inconsistency in results cache gen numbers %s (GEN-FROM-RESPONSE) != %s (GEN-FROM-STORE), not caching the response",gen,genNumberFromCtx))
level.Debug(logger).Log("msg",fmt.Sprintf("inconsistency in results cache gen numbers %s (GEN-FROM-RESPONSE) != %s (GEN-FROM-STORE), not caching the response",gen,genNumberFromCtx))