From f5091b972c2598bc434bc931ce72aea6712cc497 Mon Sep 17 00:00:00 2001 From: Ivan Ryabov Date: Fri, 28 Oct 2022 00:04:05 +1100 Subject: [PATCH] Fixed redis cache to use multi batch size Signed-off-by: Ivan Ryabov --- CHANGELOG.md | 2 +- pkg/cacheutil/redis_client.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b3d514c12..b7d45e882e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,11 +11,11 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re ## Unreleased ### Fixed - - [#5844](https://github.com/thanos-io/thanos/pull/5844) Query Frontend: Fixes @ modifier time range when splitting queries by interval. - [#5854](https://github.com/thanos-io/thanos/pull/5854) Query Frontend: Handles `lookback_delta` param in query frontend. - [#5230](https://github.com/thanos-io/thanos/pull/5230) Rule: Stateless ruler support restoring `for` state from query API servers. The query API servers should be able to access the remote write storage. - [#5880](https://github.com/thanos-io/thanos/pull/5880) Query Frontend: Fixes some edge cases of query sharding analysis. +- [#5893](https://github.com/thanos-io/thanos/pull/5893) Cache: fixed redis client not respecting `SetMultiBatchSize` config value. ### Added diff --git a/pkg/cacheutil/redis_client.go b/pkg/cacheutil/redis_client.go index a12c8d5e83..cb5a7ee2aa 100644 --- a/pkg/cacheutil/redis_client.go +++ b/pkg/cacheutil/redis_client.go @@ -239,8 +239,9 @@ func (c *RedisClient) SetMulti(ctx context.Context, data map[string][]byte, ttl keys = append(keys, k) } err := doWithBatch(ctx, len(data), c.config.SetMultiBatchSize, c.setMultiGate, func(startIndex, endIndex int) error { + currentKeys := keys[startIndex:endIndex] _, err := c.Pipelined(ctx, func(p redis.Pipeliner) error { - for _, key := range keys { + for _, key := range currentKeys { p.SetEX(ctx, key, data[key], ttl) } return nil