[release-12.2.1] Chore: Update Redis library to v9 (#112363)

This commit is contained in:
Mariell Hoversholm
2025-10-14 12:52:42 +02:00
committed by GitHub
parent e6db6c929a
commit e86240eb62
9 changed files with 40 additions and 41 deletions
+1 -1
View File
@@ -174,7 +174,6 @@ require (
github.com/go-openapi/strfmt v0.23.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-openapi/validate v0.24.0 // indirect
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/go-sql-driver/mysql v1.9.3 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
@@ -328,6 +327,7 @@ require (
github.com/prometheus/procfs v0.16.1 // indirect
github.com/prometheus/prometheus v0.303.1 // indirect
github.com/puzpuzpuz/xsync/v2 v2.5.1 // indirect
github.com/redis/go-redis/v9 v9.8.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rs/cors v1.11.1 // indirect
+5 -7
View File
@@ -311,6 +311,10 @@ github.com/blugelabs/ice/v2 v2.0.1/go.mod h1:QxAWSPNwZwsIqS25c3lbIPFQrVvT1sphf5x
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874 h1:N7oVaKyGp8bttX0bfZGmcGkjz7DLQXhAn3DNd3T0ous=
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874/go.mod h1:r5xuitiExdLAJ09PR7vBVENGvp4ZuTBeWTGtxuX3K+c=
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/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=
github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
@@ -543,8 +547,6 @@ github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI=
github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow=
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-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1aweo=
@@ -1054,8 +1056,6 @@ github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJm
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nikunjy/rules v1.5.0 h1:KJDSLOsFhwt7kcXUyZqwkgrQg5YoUwj+TVu6ItCQShw=
github.com/nikunjy/rules v1.5.0/go.mod h1:TlZtZdBChrkqi8Lr2AXocme8Z7EsbxtFdDoKeI6neBQ=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 h1:G7ERwszslrBzRxj//JalHPu/3yz+De2J+4aLtSRlHiY=
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037/go.mod h1:2bpvgLBZEtENV5scfDFEtB/5+1M4hkQhDQrccEJ/qGw=
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 h1:bQx3WeLcUWy+RletIKwUIt4x3t8n2SxavmoclizMb8c=
@@ -1069,9 +1069,8 @@ github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNs
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
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/ginkgo/v2 v2.22.2 h1:/3X8Panh8/WwhU/3Ssa6rCKqPLuAkVY2I0RoyDLySlU=
github.com/onsi/ginkgo/v2 v2.22.2/go.mod h1:oeMosUL+8LtarXBHu/c0bx2D/K9zyQ6uX3cTyztHwsk=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
@@ -2057,7 +2056,6 @@ gopkg.in/src-d/go-errors.v1 v1.0.0 h1:cooGdZnCjYbeS1zb1s6pVAAimTdKceRrpn7aKOnNIf
gopkg.in/src-d/go-errors.v1 v1.0.0/go.mod h1:q1cBlomlw2FnDBDNGlnh6X0jPihy+QxZfMMNxPCbdYg=
gopkg.in/telebot.v3 v3.2.1 h1:3I4LohaAyJBiivGmkfB+CiVu7QFOWkuZ4+KHgO/G3rs=
gopkg.in/telebot.v3 v3.2.1/go.mod h1:GJKwwWqp9nSkIVN51eRKU78aB5f5OnQuWdwiIZfPbko=
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=
+1 -1
View File
@@ -67,7 +67,7 @@ require (
github.com/go-openapi/loads v0.22.0 // @grafana/alerting-backend
github.com/go-openapi/runtime v0.28.0 // @grafana/alerting-backend
github.com/go-openapi/strfmt v0.23.0 // @grafana/alerting-backend
github.com/go-redis/redis/v8 v8.11.5 // @grafana/grafana-backend-group
github.com/go-redis/redis/v8 v8.11.5 // indirect; @grafana/grafana-backend-group
github.com/go-sourcemap/sourcemap v2.1.4+incompatible // @grafana/grafana-backend-group
github.com/go-sql-driver/mysql v1.9.3 // @grafana/grafana-search-and-storage
github.com/go-stack/stack v1.8.1 // @grafana/grafana-backend-group
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"strings"
"time"
"github.com/go-redis/redis/v8"
"github.com/redis/go-redis/v9"
"github.com/grafana/grafana/pkg/setting"
)
@@ -6,9 +6,9 @@ import (
"strings"
"testing"
"github.com/go-redis/redis/v8"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util/testutil"
"github.com/redis/go-redis/v9"
)
func TestIntegrationRedisCacheStorage(t *testing.T) {
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"fmt"
"testing"
"github.com/go-redis/redis/v8"
"github.com/redis/go-redis/v9"
"github.com/stretchr/testify/assert"
)
+1 -1
View File
@@ -14,9 +14,9 @@ import (
"time"
"github.com/centrifugal/centrifuge"
"github.com/go-redis/redis/v8"
"github.com/gobwas/glob"
jsoniter "github.com/json-iterator/go"
"github.com/redis/go-redis/v9"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
+19 -24
View File
@@ -4,11 +4,12 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"sync"
"time"
"github.com/go-redis/redis/v8"
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/redis/go-redis/v9"
"github.com/grafana/grafana/pkg/services/live/orgchannel"
)
@@ -73,40 +74,34 @@ func (c *RedisFrameCache) Update(ctx context.Context, orgID int64, channel strin
key := c.getCacheKey(orgchannel.PrependOrgID(orgID, channel))
pipe := c.redisClient.TxPipeline()
defer func() { _ = pipe.Close() }()
pipe.HGetAll(ctx, key)
pipe.HMSet(ctx, key, map[string]string{
"schema": stringSchema,
"frame": string(jsonFrame.Bytes(data.IncludeAll)),
var mapReply *redis.MapStringStringCmd
replies, err := c.redisClient.TxPipelined(ctx, func(pipe redis.Pipeliner) error {
mapReply = pipe.HGetAll(ctx, key)
pipe.HMSet(ctx, key, map[string]string{
"schema": stringSchema,
"frame": string(jsonFrame.Bytes(data.IncludeAll)),
})
pipe.Expire(ctx, key, frameCacheTTL)
return nil
})
pipe.Expire(ctx, key, frameCacheTTL)
replies, err := pipe.Exec(ctx)
if err != nil {
return false, err
}
if len(replies) == 0 {
return false, errors.New("no replies in response")
}
reply := replies[0]
if mapReply.Err() != nil {
return false, fmt.Errorf("error getting existing frame from redis: %w", mapReply.Err())
}
if reply.Err() != nil {
result, err := mapReply.Result()
if err != nil {
return false, err
}
if mapReply, ok := reply.(*redis.StringStringMapCmd); ok {
result, err := mapReply.Result()
if err != nil {
return false, err
}
if len(result) == 0 {
return true, nil
}
return result["schema"] != stringSchema, nil
if len(result) == 0 {
return true, nil
}
return true, nil
return result["schema"] != stringSchema, nil
}
func (c *RedisFrameCache) getCacheKey(channelID string) string {
@@ -1,13 +1,14 @@
package managedstream
import (
"context"
"os"
"strings"
"testing"
"github.com/go-redis/redis/v8"
"github.com/google/uuid"
"github.com/grafana/grafana/pkg/util/testutil"
"github.com/redis/go-redis/v9"
"github.com/stretchr/testify/require"
)
@@ -39,7 +40,7 @@ func TestIntegrationRedisCacheStorage(t *testing.T) {
require.NotNil(t, c)
testFrameCache(t, c)
keys, err := redisClient.Keys(redisClient.Context(), "*").Result()
keys, err := redisClient.Keys(t.Context(), "*").Result()
if err != nil {
require.NoError(t, err)
}
@@ -53,13 +54,18 @@ func TestIntegrationRedisCacheStorage(t *testing.T) {
func redisCleanup(t *testing.T, redisClient *redis.Client, prefix string) func() {
return func() {
keys, err := redisClient.Keys(redisClient.Context(), prefix+"*").Result()
ctx := t.Context()
ctx = context.WithoutCancel(ctx)
ctx, cancel := context.WithCancel(ctx)
defer cancel()
keys, err := redisClient.Keys(ctx, prefix+"*").Result()
if err != nil {
require.NoError(t, err)
}
for _, key := range keys {
_, err := redisClient.Del(redisClient.Context(), key).Result()
_, err := redisClient.Del(ctx, key).Result()
require.NoError(t, err)
}
}