Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ require (
github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb
github.com/go-kit/log v0.2.1
github.com/go-logfmt/logfmt v0.6.1
github.com/go-redis/redis/v8 v8.11.5
github.com/go-test/deep v1.1.1
github.com/gogo/protobuf v1.3.2
github.com/gogo/status v1.1.1
Expand Down Expand Up @@ -91,6 +90,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kafkareceiver v0.150.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.150.0
github.com/parquet-go/parquet-go v0.29.0
github.com/redis/go-redis/v9 v9.18.0
github.com/twmb/franz-go v1.20.7
github.com/twmb/franz-go/pkg/kadm v1.17.2
github.com/twmb/franz-go/pkg/kfake v0.0.0-20260406064450-c0fa0a167730
Expand Down
16 changes: 6 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ github.com/bits-and-blooms/bitset v1.24.2 h1:M7/NzVbsytmtfHbumG+K2bremQPMJuqv1JD
github.com/bits-and-blooms/bitset v1.24.2/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/bits-and-blooms/bloom/v3 v3.7.1 h1:WXovk4TRKZttAMJfoQx6K2DM0zNIt8w+c67UqO+etV0=
github.com/bits-and-blooms/bloom/v3 v3.7.1/go.mod h1:rZzYLLje2dfzXfAkJNxQQHsKurAyK55KUnL43Euk0hU=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
github.com/buger/jsonparser v1.1.2 h1:frqHqw7otoVbk5M8LlE/L7HTnIq2v9RX6EJ48i9AxJk=
github.com/buger/jsonparser v1.1.2/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
Expand Down Expand Up @@ -298,8 +302,6 @@ github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+Gr
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
github.com/go-openapi/validate v0.24.0 h1:LdfDKwNbpB6Vn40xhTdNZAnfLECL81w+VX3BumrGD58=
github.com/go-openapi/validate v0.24.0/go.mod h1:iyeX1sEufmv3nPbBdX3ieNviWnOZaJ1+zquzJEf2BAQ=
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
github.com/go-resty/resty/v2 v2.16.5 h1:hBKqmWrr7uRc3euHVqmh1HTHcKn99Smr7o5spptdhTM=
github.com/go-resty/resty/v2 v2.16.5/go.mod h1:hkJtXbA2iKHzJheXYvQ8snQES5ZLGKMwQ07xAwp/fiA=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
Expand Down Expand Up @@ -585,8 +587,6 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/oklog/ulid/v2 v2.1.1 h1:suPZ4ARWLOJLegGFiZZ1dFAkqzhMjL3J1TzI+5wHz8s=
Expand All @@ -599,10 +599,6 @@ github.com/olekukonko/ll v0.1.6 h1:lGVTHO+Qc4Qm+fce/2h2m5y9LvqaW+DCN7xW9hsU3uA=
github.com/olekukonko/ll v0.1.6/go.mod h1:NVUmjBb/aCtUpjKk75BhWrOlARz3dqsM+OtszpY4o88=
github.com/olekukonko/tablewriter v1.1.4 h1:ORUMI3dXbMnRlRggJX3+q7OzQFDdvgbN9nVWj1drm6I=
github.com/olekukonko/tablewriter v1.1.4/go.mod h1:+kedxuyTtgoZLwif3P1Em4hARJs+mVnzKxmsCL/C5RY=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A=
github.com/onsi/gomega v1.38.2/go.mod h1:W2MJcYxRGV63b418Ai34Ud0hEdTVXq9NW9+Sx6uXf3k=
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/zipkinexporter v0.150.0 h1:7wh2176f47Z5Zv3EwmpSG7ZaSeIJhp4eoI/Shic5R7g=
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/zipkinexporter v0.150.0/go.mod h1:h7LyiTCrPokPXGCwzRn08N3BK3iIhP5t2mwc0+Hq/eo=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.150.0 h1:/NVBt08VvI5AnWf56WwYT/N1z6ygvt07mYsfizl2Zl8=
Expand Down Expand Up @@ -731,6 +727,8 @@ github.com/puzpuzpuz/xsync/v3 v3.5.1 h1:GJYJZwO6IdxN/IKbneznS6yPkVC+c3zyY/j19c++
github.com/puzpuzpuz/xsync/v3 v3.5.1/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA=
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 h1:bsUq1dX0N8AOIL7EB/X911+m4EHsnWEHeJ0c+3TTBrg=
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/redis/go-redis/v9 v9.18.0 h1:pMkxYPkEbMPwRdenAzUNyFNrDgHx9U+DrBabWNfSRQs=
github.com/redis/go-redis/v9 v9.18.0/go.mod h1:k3ufPphLU5YXwNTUcCRXGxUoF1fqxnhFQmscfkCoDA0=
github.com/relvacode/iso8601 v1.7.0 h1:BXy+V60stMP6cpswc+a93Mq3e65PfXCgDFfhvNNGrdo=
github.com/relvacode/iso8601 v1.7.0/go.mod h1:FlNp+jz+TXpyRqgmM7tnzHHzBnz776kmAH2h3sZCn0I=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
Expand Down Expand Up @@ -1333,8 +1331,6 @@ gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
2 changes: 1 addition & 1 deletion pkg/cache/redis_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/go-redis/redis/v8"
instr "github.com/grafana/dskit/instrument"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/redis/go-redis/v9"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cache/redis_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/alicebob/miniredis/v2"
"github.com/go-kit/log"
"github.com/go-redis/redis/v8"
"github.com/redis/go-redis/v9"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
25 changes: 17 additions & 8 deletions pkg/cache/redis_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"
"unsafe"

"github.com/go-redis/redis/v8"
"github.com/redis/go-redis/v9"

"github.com/grafana/dskit/flagext"
)
Expand Down Expand Up @@ -55,6 +55,7 @@ type RedisClient struct {
expiration time.Duration
timeout time.Duration
rdb redis.UniversalClient
isCluster bool
}

// NewRedisClient creates Redis client
Expand All @@ -68,16 +69,19 @@ func NewRedisClient(cfg *RedisConfig) *RedisClient {
SentinelPassword: cfg.SentinelPassword.String(),
DB: cfg.DB,
PoolSize: cfg.PoolSize,
IdleTimeout: cfg.IdleTimeout,
MaxConnAge: cfg.MaxConnAge,
ConnMaxIdleTime: cfg.IdleTimeout,
ConnMaxLifetime: cfg.MaxConnAge,
}
if cfg.EnableTLS {
opt.TLSConfig = &tls.Config{InsecureSkipVerify: cfg.InsecureSkipVerify}
}
rdb := redis.NewUniversalClient(opt)
_, isCluster := rdb.(*redis.ClusterClient)
return &RedisClient{
expiration: cfg.Expiration,
timeout: cfg.Timeout,
rdb: redis.NewUniversalClient(opt),
rdb: rdb,
isCluster: isCluster,
}
}

Expand Down Expand Up @@ -109,7 +113,14 @@ func (c *RedisClient) MSet(ctx context.Context, keys []string, values [][]byte)
return fmt.Errorf("MSet the length of keys and values not equal, len(keys)=%d, len(values)=%d", len(keys), len(values))
}

pipe := c.rdb.TxPipeline()
// In cluster mode, cross-slot transactions are not supported. Use a non-transactional
// pipeline to allow keys on different slots, consistent with how MGet handles clusters.
var pipe redis.Pipeliner
if c.isCluster {
pipe = c.rdb.Pipeline()
} else {
pipe = c.rdb.TxPipeline()
}
Comment on lines +116 to +123
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH: This changes MSet semantics in cluster mode from (per-node) transactional to non-transactional, which can lead to partial writes if some SETs fail. If callers rely on MSet being all-or-nothing, consider either (a) documenting explicitly that cluster-mode MSet is best-effort/non-atomic, or (b) preserving atomicity when possible (e.g., if all keys map to the same hash slot, use a transaction; otherwise fall back to non-transactional pipeline).

Copilot uses AI. Check for mistakes.
Comment on lines +116 to +123
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM: The new cluster-specific behavior in MSet isn’t covered by tests. Since this is a behavioral change (avoiding CROSSSLOT by removing transactions in cluster mode), add a test that exercises the cluster/non-cluster branching. If it’s hard to stand up a real Redis Cluster in unit tests, consider extracting pipeline selection into a small helper and unit-testing that helper with a minimal stub.

Copilot generated this review using guidance from repository custom instructions.
for i := range keys {
pipe.Set(ctx, keys[i], values[i], c.expiration)
}
Expand All @@ -129,9 +140,7 @@ func (c *RedisClient) MGet(ctx context.Context, keys []string) ([][]byte, error)
// redis.UniversalClient can take redis.Client and redis.ClusterClient.
// if redis.Client is set, then Single node or sentinel configuration. mget is always supported.
// if redis.ClusterClient is set, then Redis Cluster configuration. mget may not be supported.
_, isCluster := c.rdb.(*redis.ClusterClient)

if isCluster {
if c.isCluster {
for i, key := range keys {
cmd := c.rdb.Get(ctx, key)
err := cmd.Err()
Expand Down

This file was deleted.

This file was deleted.

177 changes: 0 additions & 177 deletions vendor/github.com/go-redis/redis/v8/CHANGELOG.md

This file was deleted.

35 changes: 0 additions & 35 deletions vendor/github.com/go-redis/redis/v8/Makefile

This file was deleted.

Loading
Loading