From fdb8221cb10c66f3f8e281c1c5b7aa3e65570ac0 Mon Sep 17 00:00:00 2001 From: Marc Gravell Date: Fri, 22 May 2026 16:10:04 +0100 Subject: [PATCH 1/3] SENTINEL: defensive check around ROLE --- docs/ReleaseNotes.md | 2 +- .../ConnectionMultiplexer.Sentinel.cs | 24 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md index c7d16f61d..05925835c 100644 --- a/docs/ReleaseNotes.md +++ b/docs/ReleaseNotes.md @@ -8,7 +8,7 @@ Current package versions: ## Unreleased -- (none) +- Avoid sentinel issues if `ROLE` unavailable; fix #3064 ## 2.13.10 diff --git a/src/StackExchange.Redis/ConnectionMultiplexer.Sentinel.cs b/src/StackExchange.Redis/ConnectionMultiplexer.Sentinel.cs index 61b36b014..35276347d 100644 --- a/src/StackExchange.Redis/ConnectionMultiplexer.Sentinel.cs +++ b/src/StackExchange.Redis/ConnectionMultiplexer.Sentinel.cs @@ -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); From d640c58a94bbe07c637756c97e17ae1838a6d818 Mon Sep 17 00:00:00 2001 From: Marc Gravell Date: Fri, 22 May 2026 16:11:13 +0100 Subject: [PATCH 2/3] PR number --- docs/ReleaseNotes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md index 05925835c..009149768 100644 --- a/docs/ReleaseNotes.md +++ b/docs/ReleaseNotes.md @@ -8,7 +8,7 @@ Current package versions: ## Unreleased -- Avoid sentinel issues if `ROLE` unavailable; fix #3064 +- Avoid sentinel issues if `ROLE` unavailable; fix #3064 ([#3088 by @mgravell](https://github.com/StackExchange/StackExchange.Redis/pull/3088)) ## 2.13.10 From 521ddb49970a20ad455dbb63ffd7573d8016056e Mon Sep 17 00:00:00 2001 From: Marc Gravell Date: Fri, 22 May 2026 16:27:39 +0100 Subject: [PATCH 3/3] CI fail; try updating test-reporter --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e9553883b..9089f65c0 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -120,7 +120,7 @@ jobs: run: dotnet build Build.csproj -c Release /p:CI=true - name: StackExchange.Redis.Tests run: dotnet test tests/StackExchange.Redis.Tests/StackExchange.Redis.Tests.csproj -c Release --logger trx --logger GitHubActions --results-directory ./test-results/ /p:CI=true - - uses: dorny/test-reporter@v1 + - uses: dorny/test-reporter@v3 continue-on-error: true if: success() || failure() with: