-
Notifications
You must be signed in to change notification settings - Fork 23.5k
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
Multi-key commands about lookupKeyWrite and lookupKeyRead #7475
Comments
Makes sense, @oranagra what do you think? |
To be honest i never really understood that part and the reasoning behind it very well. But the logic in
In SUNION vs SUNIONSTORE is may be clear from the command flags, but in commands such as SORT and GEORADIUS we need to look for the STORE argument, which is what i did for SORT in this recent PR: #5390 I personally think we should continue in that path, and make the code consistent with itself, eventually we should be able to tell (and add statistics) of both considerations:
but most important is obviously not to have bugs 8-), so let's look at the differences between lookupKeyWrite and lookupKeyRead to see if something is missing. putting aside key miss keyspace notification (which is a recent addition and may be just missing from lookupKeyWrite by mistake), and putting aside statistics. It's a bit hard to read, but as far as i can tell, the only actual diff in behavior is that lookupKeyRead can return NULL on a replica if the current client is not the master, when the key already expired but not yet deleted by the master (so expireIfNeeded doesn't delete it). and even that only happens on pure READONLY commands. So the only bugs that can happen by using the wrong lookup function are when there are reads executed directly to the replica, but for these (READONLY commands), we never even consider calling lookupKeyWrite. @soloestoy @yossigo @guybe7 (@antirez) please validate my understanding / reasoning. |
@oranagra TBH i don't really see the point of knowing which "keys opened as part of read command vs write command"... |
@guybe7 i also don't see why we wanna know if the open was part of a read or write, but clearly it mattered to Pieter, and maybe to Salvatore (merged my #5390), so for now i prefer keep that indication and not use it, rather than refactor it out of the code base. i forgot about #6842, but i now realize that the problem there is not actually the use of lookupKeyRead vs lookupKeyWrite, but rather the different behavior for non-READONLY commands (which looks like a bug), more details there.. |
I agree with @guybe7 , the judgement of using Also, we need remove the check of |
Trying to sum it up:
|
For the code modification, I want to confirm:
Please tell me any other suggestions. |
…9572) Writable replicas now no longer use the values of expired keys. Expired keys are deleted when lookupKeyWrite() is used, even on a writable replica. Previously, writable replicas could use the value of an expired key in write commands such as INCR, SUNIONSTORE, etc.. This commit also sorts out the mess around the functions lookupKeyRead() and lookupKeyWrite() so they now indicate what we intend to do with the key and are not affected by the command calling them. Multi-key commands like SUNIONSTORE, ZUNIONSTORE, COPY and SORT with the store option now use lookupKeyRead() for the keys they're reading from (which will not allow reading from logically expired keys). This commit also fixes a bug where PFCOUNT could return a value of an expired key. Test modules commands have their readonly and write flags updated to correctly reflect their lookups for reading or writing. Modules are not required to correctly reflect this in their command flags, but this change is made for consistency since the tests serve as usage examples. Fixes #6842. Fixes #7475.
…edis#9572) Writable replicas now no longer use the values of expired keys. Expired keys are deleted when lookupKeyWrite() is used, even on a writable replica. Previously, writable replicas could use the value of an expired key in write commands such as INCR, SUNIONSTORE, etc.. This commit also sorts out the mess around the functions lookupKeyRead() and lookupKeyWrite() so they now indicate what we intend to do with the key and are not affected by the command calling them. Multi-key commands like SUNIONSTORE, ZUNIONSTORE, COPY and SORT with the store option now use lookupKeyRead() for the keys they're reading from (which will not allow reading from logically expired keys). This commit also fixes a bug where PFCOUNT could return a value of an expired key. Test modules commands have their readonly and write flags updated to correctly reflect their lookups for reading or writing. Modules are not required to correctly reflect this in their command flags, but this change is made for consistency since the tests serve as usage examples. Fixes redis#6842. Fixes redis#7475.
Hi,
In Redis, when we operate the key, we need
lookupKeyWrite
orlookupKeyRead
, but under the multi-key command, this flag is not strict.E.g:
According to whether dstkey exists, use lookupKeyWrite or lookupKeyRead respectively, but should only use lookupKeyRead?
Similarly, should lookupKeyRead also be used here?
If the judgment is based on the read and write attributes of the command itself, should georadius be modified to lookupKeyWrite?
I think it should be decided according to the specific operation of this key, so the above should be changed to
lookupKeyRead
.The text was updated successfully, but these errors were encountered: