-
Notifications
You must be signed in to change notification settings - Fork 1k
standalone REDIRECT: Fix scripting and further MULTI/EXEC scenarios #1781
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
base: unstable
Are you sure you want to change the base?
Conversation
727f400 to
5fdd75e
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #1781 +/- ##
============================================
- Coverage 72.43% 72.29% -0.15%
============================================
Files 128 128
Lines 70221 70248 +27
============================================
- Hits 50863 50784 -79
- Misses 19358 19464 +106
🚀 New features to boost your workflow:
|
This makes sense.
I don't understand, this already aligns with the current behavior.
Can you elaborate it? |
Mostly yes, I suppose, except when a script with no keys is used, see test case "replica allows MULTI that accesses no key". So, I think we need to look at the keys the commands within a transaction use, not only at the flags of those commands.
The proposal is to behave like in cluster mode, which basically means that EVAL and EVAL_RO do not behave differently when it comes to redirects (I think this is because In READWRITE mode on replica:
In READONLY mode on replica:
|
2398670 to
d7e26c5
Compare
@soloestoy Why do you think it makes sense? I think using watch on the replicas also makes perfect sense as the watch also protects mutations arriving on the replication stream right? I think it does not make sense to redirect watch command, but maybe I misunderstood the intension here? @gmbnomis |
Yes, |
Not sure why I need to be READONLY for that. although rare, writable replicas are still supported AFAIK. Also although I agree most known clients will issue READONLY on all replica in cluster mode disabled when rfr is used, AFAIK the READONLY was mainly introduced as a cluster command and less intended for serving cluster mode disabled. At the very least, this should be considered as a breaking change for clients. |
There is no change in the behavior of I think that a client states it intent that it wants to be redirected to the primary when it enables redirect mode.
The use of readonly and readwrite has been part of redirect mode from the beginning, see #325. So, this PR does not propose any new handling of readonly/readwrite in that mode (or any change on the client supporting redirect mode). It just fixes a couple of scenarios in which we should redirect (taking cluster mode as the reference) As for a redirected |
I understand your point (forgot that -REDIRECT will not work for writable replicas per a decision we took in #325) however maintaining the watch migrations not trivial IMO. For example say we redirect the watch and later there will be a failover switch between the primary and replica and the transaction will then be executed on the other node? |
|
@gmbnomis Also I agree that this is not an issue only with your current proposal. it is also an issue for cluster mode redirecting watch. I think there was an issue that point was discussed and we thought of introducing a new way to start a transaction with watches or something |
Anyhow, now that I understand better the suggestion I am fine with us only keeping better alignment with cluster mode MOVED. |
bc18df4 to
9caf87d
Compare
|
@soloestoy @ranshid I rebased the PR on the current unstable. This bug is now open since 8.0: I really would like to make some progress here (this bug is the reason why we do not even consider looking at using REDIRECT mode for our applications, as we use a lot of Lua scripts). |
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 <gmbnomis@gmail.com>
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:
The new logic is a heavily "distilled" version of
getNodeByQueryused 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.Fixes #868