From e61484ca7b158f4d9551ff501b601b6dc930222d Mon Sep 17 00:00:00 2001 From: Nick Craver Date: Sat, 19 Jun 2021 14:22:21 -0400 Subject: [PATCH] Unselectable flag race fix (#1773) In short, we could get in a state where `IsReplica` could be true, but we couldn't use it because it was unselectable via this path, especially on a reconnect race. This caused failures in other Sentinel testing, specifically the `NoConnectionAvailable` variety on `DemandMaster` sanity check gets, because we had a replica, it was connected, but the flags said we couldn't use it. That should _never_ be the case and this additional check at the flag set site ensures it. In testing, it looked like this (local changes here are logging this condition): ![image](https://user-images.githubusercontent.com/454813/122651716-abf78100-d108-11eb-931e-a28daa76efa6.png) --- src/StackExchange.Redis/ConnectionMultiplexer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/StackExchange.Redis/ConnectionMultiplexer.cs b/src/StackExchange.Redis/ConnectionMultiplexer.cs index c42cdef1f..a730103a3 100755 --- a/src/StackExchange.Redis/ConnectionMultiplexer.cs +++ b/src/StackExchange.Redis/ConnectionMultiplexer.cs @@ -1863,7 +1863,7 @@ internal async Task ReconfigureAsync(bool first, bool reconfigureAll, LogP var preferred = await NominatePreferredMaster(log, servers, useTieBreakers, tieBreakers, masters).ObserveErrors().ForAwait(); foreach (var master in masters) { - if (master == preferred) + if (master == preferred || master.IsReplica) { master.ClearUnselectable(UnselectableFlags.RedundantMaster); }