-
Notifications
You must be signed in to change notification settings - Fork 730
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
[BUG] "CLIENT CAPA redirect" has no effect in scripts #868
Comments
It's a little odd |
In cluster mode, the necessity of a "MOVED" response is mainly determined based on the keys of a command whereas in standalone redirect mode, the necessity of a "REDIRECT" response is determined based on the command's flags. It turns out that looking at keys is necessary. Moreover, the currently used command flags do not encompass all situations in which a REDIRECT is necessary: - WATCH command (redirect in READWRITE mode is necessary) - transactions with no keys must not be redirected - scripting scenarios: scripts (with keys) must be redirected in some situations (issue valkey-io#868). The new logic is a heavily "distilled" version of `getNodeByQuery` used in cluster mode. As we don't need to look at slots and their consistency, the information necessary is the flags of the command and whether it accesses at least one key. Signed-off-by: Simon Baatz <[email protected]>
In cluster mode, the necessity of a "MOVED" response is mainly determined based on the keys of a command whereas in standalone redirect mode, the necessity of a "REDIRECT" response is determined based on the command's flags. It turns out that looking at keys is necessary. Moreover, the currently used command flags do not encompass all situations in which a REDIRECT is necessary: - WATCH command (redirect in READWRITE mode is necessary) - transactions with no keys must not be redirected - scripting scenarios: scripts (with keys) must be redirected in some situations (issue valkey-io#868). The new logic is a heavily "distilled" version of `getNodeByQuery` used in cluster mode. As we don't need to look at slots and their consistency, the information necessary is the flags of the command and whether it accesses at least one key. Signed-off-by: Simon Baatz <[email protected]>
In cluster mode, the necessity of a "MOVED" response is mainly determined based on the keys of a command whereas in standalone redirect mode, the necessity of a "REDIRECT" response is determined based on the command's flags. It turns out that looking at keys is necessary. Moreover, the currently used command flags do not encompass all situations in which a REDIRECT is necessary: - WATCH command (redirect in READWRITE mode is necessary) - transactions with no keys must not be redirected - scripting scenarios: scripts (with keys) must be redirected in some situations (issue valkey-io#868). The new logic is a heavily "distilled" version of `getNodeByQuery` used in cluster mode. As we don't need to look at slots and their consistency, the information necessary is the flags of the command and whether it accesses at least one key. Signed-off-by: Simon Baatz <[email protected]>
@madolson Yes, it turned out that there are indeed other cases we need to take care of. I addressed the ones I am aware of in PR #1781, but there is a fundamental difference between cluster and standalone modes with respect to publish/subscribe that I don't know how to solve best. I created issue #1780 for it. |
Describe the bug
A read or write command should be redirected when issued by a client that understands "REDIRECT". This does not work when the command is part of a script.
To reproduce
Connect the CLI client to a replica and do:
(Note: I did a
set foo bar
on the primary to test replication, that's why the last command returns "bar".)Expected behavior
REDIRECT should be issued regardless of the context if the client understands redirect. (for reference, Valkey cluster issues the same "MOVED" in both cases:
)
The text was updated successfully, but these errors were encountered: