Fix accidental deletion of sinterstore command when we meet wrong type error.#9032
Conversation
|
@enjoy-binbin good catch, thank you. @redis/core-team this bug-fix is in some way a breaking change, please approve (for 7.0) |
8ba059d
oranagra
left a comment
There was a problem hiding this comment.
@enjoy-binbin that's a lot of new test code (i didn't expect that).
are you sure many of these are not already covered?
can you please make a list (or a table) of what you added, so it'll be easier to review.
i.e. if some tests existed for the non-store variant and you added them for the store variant, or some existed for UNION and you added them for INTER, and so on..
also, there there are many multi-key commands involved with this test, maybe we should hold merging it to after #9033 so that we can make sure proper tagging are added to support external sharded test targets.
|
@oranagra Yes, many of these are not covered in some tests case. The reason i added extra tests for sdiff/sunion is that: As for 9033. I am not very familiar with it. Will follow your suggestion |
…e error. (#9032) SINTERSTORE would have deleted the dest key right away, even when later on it is bound to fail on an (WRONGTYPE) error. With this change it first picks up all the input keys, and only later delete the dest key if one is empty. Also add more tests for some commands. Mainly focus on - `wrong type error`: expand test case (base on sinter bug) in non-store variant add tests for store variant (although it exists in non-store variant, i think it would be better to have same tests) - the dstkey result when we meet `non-exist key (empty set)` in *store sdiff: - improve test case about wrong type error (the one we found in sinter, although it is safe in sdiff) - add test about using non-exist key (treat it like an empty set) sdiffstore: - according to sdiff test case, also add some tests about `wrong type error` and `non-exist key` - the different is that in sdiffstore, we will consider the `dstkey` result sunion/sunionstore add more tests (same as above) sinter/sinterstore also same as above ... (cherry picked from commit b8a5da8) (cherry picked from commit f4702b8)
…e error. (#9032) SINTERSTORE would have deleted the dest key right away, even when later on it is bound to fail on an (WRONGTYPE) error. With this change it first picks up all the input keys, and only later delete the dest key if one is empty. Also add more tests for some commands. Mainly focus on - `wrong type error`: expand test case (base on sinter bug) in non-store variant add tests for store variant (although it exists in non-store variant, i think it would be better to have same tests) - the dstkey result when we meet `non-exist key (empty set)` in *store sdiff: - improve test case about wrong type error (the one we found in sinter, although it is safe in sdiff) - add test about using non-exist key (treat it like an empty set) sdiffstore: - according to sdiff test case, also add some tests about `wrong type error` and `non-exist key` - the different is that in sdiffstore, we will consider the `dstkey` result sunion/sunionstore add more tests (same as above) sinter/sinterstore also same as above ... (cherry picked from commit b8a5da8)
…e error. (redis#9032) SINTERSTORE would have deleted the dest key right away, even when later on it is bound to fail on an (WRONGTYPE) error. With this change it first picks up all the input keys, and only later delete the dest key if one is empty. Also add more tests for some commands. Mainly focus on - `wrong type error`: expand test case (base on sinter bug) in non-store variant add tests for store variant (although it exists in non-store variant, i think it would be better to have same tests) - the dstkey result when we meet `non-exist key (empty set)` in *store sdiff: - improve test case about wrong type error (the one we found in sinter, although it is safe in sdiff) - add test about using non-exist key (treat it like an empty set) sdiffstore: - according to sdiff test case, also add some tests about `wrong type error` and `non-exist key` - the different is that in sdiffstore, we will consider the `dstkey` result sunion/sunionstore add more tests (same as above) sinter/sinterstore also same as above ...
|
Late realization: this fix could cause data inconsistency between the master and the replica. |
In
sunioncommand, if we type any keys wrong(like type error), there will be an errorIn sinter command, it will be different. In sinter command, i think the result will be fine(although unlike sunion)
But in sinterstore command, the different will cause totally different about the
dstkey.So i update
sinterGenericCommand, and make them behave uniformly. After output:Also add more tests for some commands.
Mainly focus on
wrong type error:expand test case (base on sinter bug) in non-store variant
add tests for store variant (although it exists in non-store variant, i think it would be better to have same tests)
non-exist key (empty set)in *storesdiff:
sdiffstore:
wrong type errorandnon-exist keydstkeyresultsunion/sunionstore add more tests (same as above)
sinter/sinterstore also same as above ...