Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different behavior on the 2 write(del and set) commands with the PreferReplica flags. #2821

Open
czd890 opened this issue Dec 2, 2024 · 0 comments

Comments

@czd890
Copy link

czd890 commented Dec 2, 2024

// 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(...)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant