-
Notifications
You must be signed in to change notification settings - Fork 767
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 ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## unstable #1781 +/- ##
============================================
- Coverage 71.18% 71.00% -0.18%
============================================
Files 123 123
Lines 65619 65698 +79
============================================
- Hits 46712 46652 -60
- Misses 18907 19046 +139
🚀 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:
|
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:
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.Fixes #868