Repository navigation
Fix zero-ordering SORT when called against lists - #2094
Conversation
People mostly use SORT against lists, but our prior behavior was pretending lists were an unordered bag requiring a forced-sort when no sort was requested. We can just use the native list ordering to ensure consistency across replicaion and scripting calls. Closes redis#2079 Closes redis#545 (again)
|
Hello Matt, from the code I see you changed the condition from: to So before the sort was performed only if the following set of conditions where met at the same time:
Now the new condition is:
If we compute the difference between the two, when the new code will force the sorting with the new condition, where the old condition would not sort it?
When instead the new code path would skip sorting while the old one would sort it?
I think that skipping sorting for Lua and STORE if the type is a list is good, but now we are sorting the output even when not needed, which is, when a Set is fetched via SORT by a normal client not using store. So my proposal is to change the if condition into the following: This way we still skip sorting for Lists and Sorted Sets, but we avoid sorting for sets when there is no need to do so and we are free to return unsorted elements. |
That certainly works too.
The key word there is "need" — it seems confusing if a command returns different results in scripting vs. not-scripting. Forcing "always sort type SET" removes potential user confusion. 😕 |
|
Hello Matt, this is my reasoning and why I think it is important to don't sort in the case it's a normal client:
That's why I'm more inclined to change the conditional to what I proposed. |
|
Btw, merging your original commit and doing the trivial change myself: it is easy and captures the full story given that here there were two possibilities :-) |
Fix zero-ordering SORT when called against lists
|
Done, thank you. Back ported to 2.8 and testing as well. |
People mostly use SORT against lists, but our prior
behavior was pretending lists were an unordered bag
requiring a forced-sort when no sort was requested.
We can just use the native list ordering to ensure
consistency across replicaion and scripting calls.
Tests added too (they fail before this commit).
Closes #2079
Closes #545 (again)