Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit fe65bd6

Browse files
committed
only listen for messages from current sentinel host
1 parent fd307c7 commit fe65bd6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/ServiceStack.Redis/RedisSentinelWorker.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ internal class RedisSentinelWorker : IDisposable
1717
private readonly RedisEndpoint sentinelEndpoint;
1818
private readonly RedisSentinel sentinel;
1919
private readonly RedisClient sentinelClient;
20-
private RedisPubSubServer sentinePubSub;
20+
private RedisPubSubServer sentinelPubSub;
2121

2222
public Action<Exception> OnSentinelError;
2323

2424
public RedisSentinelWorker(RedisSentinel sentinel, RedisEndpoint sentinelEndpoint)
2525
{
2626
this.Id = Interlocked.Increment(ref IdCounter);
2727
this.sentinel = sentinel;
28+
this.sentinelEndpoint = sentinelEndpoint;
2829
this.sentinelClient = new RedisClient(sentinelEndpoint) {
2930
Db = 0, //Sentinel Servers doesn't support DB, reset to 0
3031
ConnectTimeout = sentinel.SentinelWorkerConnectTimeoutMs,
@@ -167,18 +168,19 @@ public void BeginListeningForConfigurationChanges()
167168
{
168169
lock (oLock)
169170
{
170-
if (this.sentinePubSub == null)
171+
if (this.sentinelPubSub == null)
171172
{
172-
var sentinelManager = new BasicRedisClientManager(sentinel.SentinelHosts, sentinel.SentinelHosts)
173+
var currentSentinelHost = new[] {sentinelEndpoint};
174+
var sentinelManager = new BasicRedisClientManager(currentSentinelHost, currentSentinelHost)
173175
{
174176
//Use BasicRedisResolver which doesn't validate non-Master Sentinel instances
175-
RedisResolver = new BasicRedisResolver(sentinel.SentinelEndpoints, sentinel.SentinelEndpoints)
177+
RedisResolver = new BasicRedisResolver(currentSentinelHost, currentSentinelHost)
176178
};
177179

178180
if (Log.IsDebugEnabled)
179181
Log.Debug($"Starting subscription to {sentinel.SentinelHosts.ToArray()}, replicas: {sentinel.SentinelHosts.ToArray()}...");
180182

181-
this.sentinePubSub = new RedisPubSubServer(sentinelManager)
183+
this.sentinelPubSub = new RedisPubSubServer(sentinelManager)
182184
{
183185
HeartbeatInterval = null,
184186
IsSentinelSubscription = true,

0 commit comments

Comments
 (0)