Add readonly flag to EVAL_RO, EVALSHA_RO and FCALL_RO#10728
Add readonly flag to EVAL_RO, EVALSHA_RO and FCALL_RO#10728madolson merged 8 commits intoredis:unstablefrom
Conversation
oranagra
left a comment
There was a problem hiding this comment.
your change had some undesired side effects.
and i'm still not sure i agree with the desired ones, but let's keep discussing it on the other thread.
|
@madolson @yossigo i added a #8820 (comment) in the original PR, and also an "UPDATE" note on the top comment linking to that comment and this PR. |
|
Adding some documentation is likely a good idea. Maybe just documenting that that EVAL_RO is useful in specific circumstances, and EVAL + no-write flag is just as good in most situations. |
|
yes, i think we need to mention something like:
put some of that in the top comment for the purpose of the release notes, and some in redis-io. |
|
@madolson I edited the top comment, removed all the doc text about read-only scripts and left just the part about the purpose of the read-only commands. feel free to re-edit. |
@madolson can you point me to the code that backs that? |
|
another side effect is now these commands will let /* Prevent a replica from sending commands that access the keyspace.
* The main objective here is to prevent abuse of client pause check
* from which replicas are exempt. */
if ((c->flags & CLIENT_SLAVE) && (is_may_replicate_command || is_write_command || is_read_command)) {
rejectCommandFormat(c, "Replica can't interact with the keyspace");
return C_OK;
}the change is in #8868, but I think we should only allow slave (not monitor) client execute |
yeah, for clients the READONLY flag may mean they can send it to replicas, and for redis that flags has a completely different meaning. i.e. a command without READONLY or WRITE is one that doesn't touch the keyspace, and a command with either one of them is one that does touch the keyspace. |
Based on discussion from redis/redis#10728 (comment), want to better define when to use `EVAL` et. al vs `EVAL_RO` et al. to be modified again soon in #1954
@oranagra It's just right there. Maybe my point didn't come across exactly right. EVAL behaves the way I described, it only tracks "declared" keys. I believe that EVAL_RO should behave the "same" as EVAL when executing the same set of commands. A question I asked in the top was if we wanted to maintain the current behavior. The more "logical" behavior is that we should track keys based off of the commands being executed by the |
|
ok i see now...
is that something i'm still missing or a mistake in the comment? anyway, could it be that this behavior is an innocent mistake? i.e. the tracking mechanism needs the real client since that's the client that should be reported to, so maybe the fact it takes the wrong command was unintended? do you remember any discussion around that? either way, i suggest we merge this PR as is (sets the flags to EVAL_RO and keeps the caching behavior as it was), and consider a change in the caching logic in a followup PR. |
Oh, yeah, that isn't correct. I think that's how I thought it worked when I started working on the PR, and later learned it was even weirder than I thought. I updated the top comment to also clarify that the behavior actually didn't change.
I think it's an honest mistake or perhaps just an optimization. I don't remember any conversation around this.
Agree, updated the top comment and will merge now. |
README updates, moving from dictionary.txt -> wordlist adding spellchecker-cli to wordlist. . . so meta Update README about clients (redis#1886) Add documentation documenting read-only scripts (redis#1953) Based on discussion from redis/redis#10728 (comment), want to better define when to use `EVAL` et. al vs `EVAL_RO` et al. to be modified again soon in redis#1954 Add info fields about network bytes during replication. (redis#1966) Co-authored-by: jiangyujie.jyj <[email protected]> Update key-specs.md (redis#1963) Fix "incomplete flag section" internal page link Update install-redis-on-windows.md (redis#1967) Duplicate "install" word. Update command-getkeysandflags.md (redis#1946) Update install-redis-on-mac-os.md (redis#1938) Small grammar fixes fix incorrect link (redis#1926) Add CLUSTER INFO fields (redis#1798) script flags update (redis#1954) updating docs about read only scripts and oom related flag changes in 7.0.1 minor fixes adding spellcheck config and commands file adding workflow dispatch newline newline debug newline duh whitespace more whitespace this ought to do it. this ought to do it. alright, this really ought to do it. no clobber just ignore COMMAND_FILES* pointing at main
* Add readonly flag to EVAL_RO, EVALSHA_RO and FCALL_RO * Require users to explicitly declare @scripting to get access to lua scripting.
This PR does two things:
@scriptingto get access to lua scripting. EVAL is not added with@write, so I don't think@readshould give access to EVAL_RO.A note about client side tracking: Client side tracking detects all commands marked with
READ-ONLYand then tracks all of the keys that command declares. The exception to this rule is the EVAL command, which when it's scripting client executes a "READONLY" command it starts tracking all the keys declared by the EVAL script. There is some logic added so that the *_RO scripting command emulate this behavior.Release notes information
The motivation is that many clients also better support routing the read-only script commands to replicas for applications that want to use replicas for read scaling.
A minor secondary motivation is that administrators may want to restrict developers from writing allow-write scripts.
The recommended approach is to use the standard scripting commands with the
no-writesflag unless you need one of the previously mentioned features.