-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Remove EVAL script verbatim replication, propagation, and deterministic execution logic #9812
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
Remove EVAL script verbatim replication, propagation, and deterministic execution logic #9812
Conversation
|
Good work! ping @redis/core-team to review. About scripts persisting, I prefer NO, since we never guarantee scripts could be persisted, and as antirez said, it can make replication clearer. And I think we can allow eviction in lua now, fix issue #8478. |
|
@zhugezy thank you and welcome. Regarding the persistence, the EVAL design was very clear from the get go that clients can't assume the script is cached, and the EVALSHA is an optimization that the client should be prepared for any case the script is not cached. In redis 4.0, because of PSYNC2, these cases where the script is missing got rarer, so users may have got accustomed to it. |
Oh I didn't notice it, maybe you mean this approach #8478 (comment)? But I think after this PR we can allow eviction in lua just like |
|
I thought we agreed that both of these will be assigned to Yoav, but maybe don't recall something. Regarding the OOM, even if we allow eviction, the problem still exists since the server might be configured not to allow eviction. And also, there's the other discussion to make about deterministic execution (which I mentioned above but left for Yossi to present), which may lead to concluding that we still can't evict inside a script. |
|
Let's first debate about propagation and persistence. |
|
Persistence and replication: the actual guarantee as documented was never very clear and at some point (#5292 (comment)) it was limited to the scope of a single connection (although Redis 7 and Redis Functions is a good opportunity to clean this up and re-set the client expectations, so I think it makes sense to completely drop script replication. Eviction: I'm not in favor of that. While it's not strictly needed for consistency any longer, I think guaranteeing atomicity is still good practice, especially given that scripts are not designed to be long running. Having scripts suddenly see keys vanishing keys during execution in Redis 7 seems like a problem to me. Deterministic execution: This too is not strictly needed but I think not being able to enforce it, at least optionally, is a potential regression. I think it's reasonable to expect identical results if you run the same script on multiple instances with the same dataset (e.g. running tests scenarios on different envs, prod vs. staging/dev, etc.). |
|
Stage summary: looks like we have reached a consensus that script persistence/replication can & should be dropped, and haven't seen any objections in the past few days. If it's done, then we can move onto the next topic. For deterministic execution, I think non-deterministic results are consistent with users' expectations when they put "random" commands in scripts/functions and send them to multiple instances, while deterministic may not. So why bother making the result deterministic? Anyway, it would be better if someone could cite their examples about it. |
|
@zhugezy we had a discussion about this these topics in a core-team meeting today.
but then we realized that since regarding script persistence and replication, as was said before, it was never meant to be persisted and replicated, and even if some users started getting accustomed to it since PSYNC2, it's actually likely that it'll cause them bugs, since the scripts are sometimes replicated, but they're never persisted. we wanna proceed and delete that feature completely. so i think the next step is to wait for the functions PR to be merged, and then re-do this deletion work. |
|
@oranagra Totally agreed. |
|
i think you can just force-push the new version into it when it's ready. |
|
btw, i see this PR doesn't remove the |
|
@oranagra Oh, I didn't notice this test... I just checked all tests in scripting.tcl, tests with keywords like "lua-replicate-commands","redis.replicate_commands" or else and other failed tests, which I thought are all of them. I'll check other test files later. |
8314750 to
64f6159
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mostly LGTM.
@MeirShpilraien @yoav-steinberg please take a look
oranagra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohh, i now realized that for some reason i only looked at the second commit.
edited my comment.
|
@zhugezy we discussed script persistence and propagation in a core-team meeting and concluded we want them removed. also, we'll need to remove the excessive command flags soon, but let's do it after #9656 is merged. i added these to a |
|
@zhugezy i remind you about |
|
@redis/core-team please approve (see top comment for a list of what's included and excluded) |
itamarhaber
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removal of script replication gladly approved (not a CR)
yossigo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List of changes in top comment LGTM, did not do a complete code review.
Adding command tips (see https://redis.io/topics/command-tips) to commands. Breaking changes: 1. Removed the "random" and "sort_for_script" flags. They are now command tips. (this isn't affecting redis behavior since #9812, but could affect some client applications that's relying on COMMAND command flags) Summary of changes: 1. add BLOCKING flag (new flag) for all commands that could block. The ACL category with the same name is now implicit. 2. move RANDOM flag to a `nondeterministic_output` tip 3. move SORT_FOR_SCRIPT flag to `nondeterministic_output_order` tip 3. add REQUEST_POLICY and RESPONSE_POLICY where appropriate as documented in the tips 4. deprecate (ignore) the `random` flag for RM_CreateCommand Other notes: 1. Proxies need to send `RANDOMKEY` to all shards and then select one key randomly. The other option is to pick a random shard and transfer `RANDOMKEY `to it, but that scheme fails if this specific shard is empty 2. Remove CMD_RANDOM from `XACK` (i.e. XACK does not have RANDOM_OUTPUT) It was added in 9e4fb96, I guess by mistake. Also from `(P)EXPIRETIME` (new command, was flagged "random" by mistake). 3. Add `nondeterministic_output` to `OBJECT ENCODING` (for the same reason `XTRIM` has it: the reply may differ depending on the internal representation in memory) 4. RANDOM on `HGETALL` was wrong (there due to a limitation of the old script sorting logic), now it's `nondeterministic_output_order` 5. Unrelated: Hide CMD_PROTECTED from COMMAND
It was first added to load lua from RDB, see 28dfdca. After redis#9812, we no longer save lua in RDB. luaCreateFunction will only be called in script load and eval*, both of which are available in the client. Remove the dead code and comments to avoid misunderstandings.
It was first added to load lua from RDB, see 28dfdca. After #9812, we no longer save lua in RDB. luaCreateFunction will only be called in script load and eval*, both of which are available in the client. It could be that that some day we'll still want to load scripts from somewhere that's not a client. This fix is in dead code.
Background
The main goal of this PR is to remove relevant logics on Lua script verbatim replication, only keeping effects replication logic, which has been set as default since Redis 5.0. As a result, Lua in Redis 7.0 would be acting the same as Redis 6.0 with default configuration from users' point of view.
To get you back on track if you are not keeping eyes on it, please refer to these issues/PRs: PR#4966, Issue#5292, Issue#8370 .
There are lots of reasons to remove verbatim replication. Antirez has listed some of the benefits in Issue#5292:
When looking back at Redis 5.0, antirez and core team decided to set the config
lua-replicate-commands yesby default instead of removing verbatim replication directly, in case some bad situations happened. 3 years later now before Redis 7.0, it's time to remove it formally.Changes
redis.replicate_commands()&redis.set_repl()changedredis.replicate_commands()does nothing and return an 1redis.set_repl()can be issued beforeredis.replicate_commands()nowOther changes
Thoughts & Discussions
NOSCRIPTerror.NOSCRIPTerror too.