Repository navigation
fix(redis): require primary command routing - #11484
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused routing correction is consistent across affected operations and has targeted regression coverage.
0 open findings
What changed in this PR
Ensures Redis membership and grain-directory operations route to the primary, preventing replica READONLY errors and stale reads.
Changes:
- Adds
DemandMasterwhile preservingNoScriptCache. - Routes directory lookups and membership snapshots to the primary.
- Adds regression coverage for command flags and existing cancellation behavior.
| File | Description |
|---|---|
RedisGrainDirectory.cs |
Enforces primary routing for directory operations. |
RedisMembershipTable.cs |
Enforces primary routing for membership commands. |
RedisGrainDirectoryUnitTests.cs |
Tests directory routing flags. |
RedisMembershipTableTests.cs |
Updates cleanup integration coverage. |
RedisMembershipTableCancellationTests.cs |
Tests membership flags and cancellation behavior. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code coverage
Report-only conclusion: regressed. The current-main baseline is commit Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities. The comparison remains report-only while normal line and branch variance is calibrated. Coverage details |
(cherry picked from commit bdc6d4f) Upstream-PR: dotnet#11484 Upstream-Commit: bdc6d4f
Redis membership and grain-directory scripts can be routed to a connected replica while the primary reconnects because StackExchange.Redis permits replica routing for EVAL/EVALSHA. Replicas reject these writes with READONLY errors, and replica-served membership snapshots or directory lookups can expose stale state.
Require
CommandFlags.DemandMasterfor membership scripts and snapshots, and for grain-directory registration/unregistration scripts and lookups. PreserveNoScriptCacheon membership scripts and the established primary-only routing of native write commands. This enforces the providers' existing write and current-registration guarantees using their existing contracts.Reuses the verified five-file correction published in #11476, applied to current main. Regression coverage captures the actual command flags and preserves cancellation, ownership, and cleanup-race behavior.
Fixes #11473.
Related proposal: #11476.
Microsoft Reviewers: Open in CodeFlow