Skip to content

Commit 9015e98

Browse files
authored
support sentinel TopologyRefreshInterval (#1201)
1 parent ef3ac33 commit 9015e98

3 files changed

Lines changed: 26 additions & 11 deletions

File tree

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/aws/aws-sdk-go-v2/service/sqs v1.46.5
1515
github.com/aws/aws-sdk-go-v2/service/sts v1.45.5
1616
github.com/aws/smithy-go v1.27.7
17-
github.com/centrifugal/centrifuge v0.38.1-0.20260812044137-a63771cce903
17+
github.com/centrifugal/centrifuge v0.38.1-0.20260812170737-ccb335a5d97b
1818
github.com/centrifugal/protocol v0.20.1-0.20260811164823-815457ed4d09
1919
github.com/cristalhq/jwt/v5 v5.4.0
2020
github.com/go-viper/mapstructure/v2 v2.5.0
@@ -39,7 +39,7 @@ require (
3939
github.com/stretchr/testify v1.11.1
4040
github.com/tidwall/gjson v1.19.0
4141
github.com/tidwall/sjson v1.2.5
42-
github.com/twmb/franz-go v1.21.5
42+
github.com/twmb/franz-go v1.21.6
4343
github.com/twmb/franz-go/pkg/kadm v1.18.0
4444
github.com/twmb/franz-go/pkg/kmsg v1.13.1
4545
github.com/valyala/fasttemplate v1.2.2
@@ -128,7 +128,7 @@ require (
128128
github.com/prometheus/common v0.70.1 // indirect
129129
github.com/prometheus/procfs v0.21.1 // indirect
130130
github.com/quic-go/qpack v0.6.0 // indirect
131-
github.com/redis/rueidis v1.0.76
131+
github.com/redis/rueidis v1.0.77-0.20260811083940-91dfdfd3b348
132132
github.com/segmentio/asm v1.2.1 // indirect
133133
github.com/segmentio/encoding v0.5.4
134134
github.com/spf13/cast v1.10.0 // indirect

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r
7373
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
7474
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
7575
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
76-
github.com/centrifugal/centrifuge v0.38.1-0.20260812044137-a63771cce903 h1:WLW8wcahmGCnNABQ5QSMq50IcHNbN6QVV6Doq4D1mhs=
77-
github.com/centrifugal/centrifuge v0.38.1-0.20260812044137-a63771cce903/go.mod h1:ETqrSYvOTIJhPg3BmEzSAF9ok/XK77HVObFkXWFGCNg=
76+
github.com/centrifugal/centrifuge v0.38.1-0.20260812170737-ccb335a5d97b h1:vxak6TBgKi0GyjDexinQ8xuUBHl65tSpmuSckI7fohg=
77+
github.com/centrifugal/centrifuge v0.38.1-0.20260812170737-ccb335a5d97b/go.mod h1:9d+DLsD9PDJrVKitBtQ2Yw+EmkdMXiN+0MD7oDpwBqw=
7878
github.com/centrifugal/protocol v0.20.1-0.20260811164823-815457ed4d09 h1:8SJBvmcS/KXNu8h/79VyYgey4WNreVM9NR3NrGNLFSQ=
7979
github.com/centrifugal/protocol v0.20.1-0.20260811164823-815457ed4d09/go.mod h1:3pinAfcb+bH8Yp8Ewhf9QTRTzsQ9veP/QOrCk5D5SSE=
8080
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
@@ -251,8 +251,8 @@ github.com/quic-go/webtransport-go v0.12.0 h1:CpnKNwZvdV0LD73xoHO8QaR0NI3llqpWRw
251251
github.com/quic-go/webtransport-go v0.12.0/go.mod h1:GHne8aRFJ24h73pAMrcywXtuaz/ShBXCLXLvG/NPFdU=
252252
github.com/rakutentech/jwk-go v1.2.0 h1:vNJwedPkRR+32V5WGNj0JP4COes93BGERvzQLBjLy4c=
253253
github.com/rakutentech/jwk-go v1.2.0/go.mod h1:pI0bYVntqaJ27RCpaC75MTUacheW0Rk4+8XzWWe1OWM=
254-
github.com/redis/rueidis v1.0.76 h1:RdDWuvlYBSp+bTrBvaXqJnNEL3VVzsnjo+0psPFgLc4=
255-
github.com/redis/rueidis v1.0.76/go.mod h1:UsfHPSbomB6QAVMk4iiFkzRy0nh9o7scDGa+SitvBY4=
254+
github.com/redis/rueidis v1.0.77-0.20260811083940-91dfdfd3b348 h1:ShhM52F+S4XJ937CmGnx0cGgZsfBB+Zp0Tr48VoxLLo=
255+
github.com/redis/rueidis v1.0.77-0.20260811083940-91dfdfd3b348/go.mod h1:UsfHPSbomB6QAVMk4iiFkzRy0nh9o7scDGa+SitvBY4=
256256
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
257257
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
258258
github.com/rs/zerolog v1.35.1 h1:m7xQeoiLIiV0BCEY4Hs+j2NG4Gp2o2KPKmhnnLiazKI=
@@ -302,8 +302,8 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
302302
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
303303
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
304304
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
305-
github.com/twmb/franz-go v1.21.5 h1:cVYI2+JTTKSvohhy8bCOleYrS7G79ZBrLVFIJsoHm8M=
306-
github.com/twmb/franz-go v1.21.5/go.mod h1:rfoMTnVk7107fhTGxfEKIHP/e7tPe6oyij/ywzO0czk=
305+
github.com/twmb/franz-go v1.21.6 h1:+v0dQJVIIuw9uPmPWmPrkoUHs1pPeV8MSwA4eU/Y2kY=
306+
github.com/twmb/franz-go v1.21.6/go.mod h1:wMepkgCatAdV9vCsuwM+wr+C1fl7KV/41+uHGAjt/wc=
307307
github.com/twmb/franz-go/pkg/kadm v1.18.0 h1:WRf/LZmDdcDXwX7WMbtDU++v+b3NzYh2bCGoPMmzirw=
308308
github.com/twmb/franz-go/pkg/kadm v1.18.0/go.mod h1:XeLhGoLXLFzK8/ryv5FfpxPxGwj4oFEGpPJMB/x6KDE=
309309
github.com/twmb/franz-go/pkg/kmsg v1.13.1 h1:fG5kItwysTk5UXqVwb64EpQEy3TydF3vYYK21nUQ+bI=

internal/redisshard/shard.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ import (
1818
const (
1919
defaultRedisIOTimeout = 4 * time.Second
2020
defaultRedisConnectTimeout = time.Second
21+
22+
// sentinelTopologyRefreshInterval makes the Sentinel client periodically
23+
// re-check its targets with Sentinels instead of relying solely on the
24+
// +switch-master event. That event is the only way the client learns about
25+
// a failover, and it can be missed — a demoted master keeps its connection
26+
// alive and a role change sends no MOVED, so a client which missed the
27+
// event stays pinned to a node that is now a read-only replica until
28+
// restart. This is easy to hit with a Sentinel co-located with each Redis
29+
// node (as in the Bitnami Redis Helm chart), where the client loses its
30+
// Sentinel connection at the same moment the master dies and Redis PUB/SUB
31+
// does not replay the missed message.
32+
sentinelTopologyRefreshInterval = 5 * time.Second
2133
)
2234

2335
type RedisShard struct {
@@ -103,8 +115,11 @@ func NewRedisShard(conf RedisShardConfig) (*RedisShard, error) {
103115
addressOpts.ClientOption, addressOpts.IsCluster, addressOpts.IsSentinel, addressOpts.ReplicaClientEnabled
104116
}
105117

106-
if isSentinel && options.Sentinel.MasterSet == "" {
107-
return nil, errors.New("sentinel master name must be configured for Redis Sentinel setup")
118+
if isSentinel {
119+
if options.Sentinel.MasterSet == "" {
120+
return nil, errors.New("sentinel master name must be configured for Redis Sentinel setup")
121+
}
122+
options.Sentinel.TopologyRefreshInterval = sentinelTopologyRefreshInterval
108123
}
109124

110125
client, err := rueidis.NewClient(options)

0 commit comments

Comments
 (0)