StackExchange / StackExchange/StackExchange.Redis
Different behavior on the 2 write(del and set) commands with the PreferReplica flags.
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.2k
- Forks
- 1.6k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 43
Description
// it throws RedisCommandException: Command cannot be issued to a replica.
KeyDeleteAsync("a", CommandFlags.PreferReplica);
// successfully.
StringSetAsync("a", "a", flags: CommandFlags.PreferReplica);
The difference comes from the different timing of calling SelectServer.
del will use Select(command, key, flags) to select a server before building the Message (determines whether to use del or unlink depending on the server version).
And the set command will select a server in PrepareToPushMessageToBridge based on message.flags (determined by IsPrimaryOnly()).
we should use Select(command, key, DemandMaster) to fix for del and other commands(like pexpire,expire) or throw ExceptionFactory.PrimaryOnly(...)?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing KeyDeleteAsync and StringSetAsync through Select(command, key, flags), IsPrimaryOnly(), and PrepareToPushMessageToBridge. Reproduce both commands with CommandFlags.PreferReplica, then determine whether the behavior should consistently demand a primary or raise PrimaryOnly; done means the affected write commands behave consistently and the regression is covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, redis
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100