Fix zuiFind crash / RM_ScanKey hang on SET object listpack encoding#11581
Fix zuiFind crash / RM_ScanKey hang on SET object listpack encoding#11581oranagra merged 12 commits intoredis:unstablefrom
Conversation
In redis#11290, we added listpack encoding for SET object, but forgot to support it in zuiFind. Causing for example ZDIFF command to act on the SET object, it will crash. This PR add support SET listpack in zuiFind, and add tests for related commands to cover this case. Fixes redis#11578
zuiderkwast
left a comment
There was a problem hiding this comment.
Thanks @enjoy-binbin for fixing this and thanks @hbina for reporting this issue so it can be fixed before Redis 7.2 is released!
It's embarrassing that I missed this function when I implemented listpack encoding for sets.
zuiderkwast suggest: there is no reason for zuiFind to go into the internals of the set. It can simply use setTypeIsMember and don't care about encoding. Co-authored-by: Viktor Söderqvist <[email protected]>
Co-authored-by: Viktor Söderqvist <[email protected]>
zuiderkwast
left a comment
There was a problem hiding this comment.
LGTM
Thanks for doing the extra (slightly unrelated) refactoring! I wouldn't have required it but it's an improvement definitely.
|
do we wanna take this opportunity and improve the hash scan code to use lpGetValue instead of lpGet? |
oranagra
left a comment
There was a problem hiding this comment.
great.
can you please update the top comment to mention the additional changes and their implications (performance)
…edis#11581) In redis#11290, we added listpack encoding for SET object. But forgot to support it in zuiFind, causes ZINTER, ZINTERSTORE, ZINTERCARD, ZIDFF, ZDIFFSTORE to crash. And forgot to support it in RM_ScanKey, causes it hang. This PR add support SET listpack in zuiFind, and in RM_ScanKey. And add tests for related commands to cover this case. Other changes: - There is no reason for zuiFind to go into the internals of the SET. It can simply use setTypeIsMember and don't care about encoding. - Remove the `#include "intset.h"` from server.h reduce the chance of accidental intset API use. - Move setTypeAddAux, setTypeRemoveAux and setTypeIsMemberAux interfaces to the header. - In scanGenericCommand, use setTypeInitIterator and setTypeNext to handle OBJ_SET scan. - In RM_ScanKey, improve hash scan mode, use lpGetValue like zset, they can share code and better performance. The zuiFind part fixes redis#11578 Co-authored-by: Oran Agra <[email protected]> Co-authored-by: Viktor Söderqvist <[email protected]>
…edis#11581) In redis#11290, we added listpack encoding for SET object. But forgot to support it in zuiFind, causes ZINTER, ZINTERSTORE, ZINTERCARD, ZIDFF, ZDIFFSTORE to crash. And forgot to support it in RM_ScanKey, causes it hang. This PR add support SET listpack in zuiFind, and in RM_ScanKey. And add tests for related commands to cover this case. Other changes: - There is no reason for zuiFind to go into the internals of the SET. It can simply use setTypeIsMember and don't care about encoding. - Remove the `#include "intset.h"` from server.h reduce the chance of accidental intset API use. - Move setTypeAddAux, setTypeRemoveAux and setTypeIsMemberAux interfaces to the header. - In scanGenericCommand, use setTypeInitIterator and setTypeNext to handle OBJ_SET scan. - In RM_ScanKey, improve hash scan mode, use lpGetValue like zset, they can share code and better performance. The zuiFind part fixes redis#11578 Co-authored-by: Oran Agra <[email protected]> Co-authored-by: Viktor Söderqvist <[email protected]>
In #11290, we added listpack encoding for SET object.
But forgot to support it in zuiFind, causes ZINTER, ZINTERSTORE,
ZINTERCARD, ZIDFF, ZDIFFSTORE to crash.
And forgot to support it in RM_ScanKey, causes it hang.
This PR add support SET listpack in zuiFind, and in RM_ScanKey.
And add tests for related commands to cover this case.
Other changes:
It can simply use setTypeIsMember and don't care about encoding.
#include "intset.h"from server.h reduce the chance ofaccidental intset API use.
interfaces to the header.
to handle OBJ_SET scan.
they can share code and better performance.
The zuiFind part fixes #11578