Skip to content
Open
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 docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Current package versions:

## Unreleased

- (none)
- Avoid sentinel issues if `ROLE` unavailable; fix #3064 ([#3088 by @mgravell](https://github.com/StackExchange/StackExchange.Redis/pull/3088))

## 2.13.10

Expand Down
24 changes: 21 additions & 3 deletions src/StackExchange.Redis/ConnectionMultiplexer.Sentinel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,28 @@ public ConnectionMultiplexer GetSentinelMasterConnection(ConfigurationOptions co

// verify role is primary according to:
// https://redis.io/topics/sentinel-clients
if (connection.GetServer(newPrimaryEndPoint)?.Role()?.Value == RedisLiterals.master)
bool isPrimary;
var server = connection.GetServer(newPrimaryEndPoint);
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
if (server is { })
{
success = true;
break;
try
{
isPrimary = connection.CommandMap.IsAvailable(RedisCommand.ROLE)
? server.Role()?.Value == RedisLiterals.master
: !server.IsReplica;
}
catch
{
// fallback if ROLE unavailable but not declared; see #3064
isPrimary = !server.IsReplica;
}

if (isPrimary)
{
success = true;
break;
}
}

Thread.Sleep(100);
Expand Down
Loading