-
Notifications
You must be signed in to change notification settings - Fork 986
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
smembers returns elements in non-deterministic order #823
Labels
Milestone
Comments
Good catch and thanks a lot for the bug report. The problem is indeed that |
mp911de
added a commit
that referenced
this issue
Jul 27, 2018
Lettuce now retains the response order for set results such as smembers. Previously, we used a plain HashSet that did not honor insertion order. Now we're using LinkedHashSet that retains the insertion order for unique elements.
mp911de
added a commit
that referenced
this issue
Jul 27, 2018
Lettuce now retains the response order for set results such as smembers. Previously, we used a plain HashSet that did not honor insertion order. Now we're using LinkedHashSet that retains the insertion order for unique elements.
mp911de
added a commit
that referenced
this issue
Jul 27, 2018
Lettuce now retains the response order for set results such as smembers. Previously, we used a plain HashSet that did not honor insertion order. Now we're using LinkedHashSet that retains the insertion order for unique elements.
mp911de
added a commit
that referenced
this issue
Jul 27, 2018
Lettuce now retains the response order for set results such as smembers. Previously, we used a plain HashSet that did not honor insertion order. Now we're using LinkedHashSet that retains the insertion order for unique elements.
That's fixed now for all maintained branches (4.x, 4.4.x, 5.0.x, 5.x/master). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm using Repositories from spring-data-redis, and I noticed that some of my tests against data repositories is unstable, sometimes they all passes, sometimes one of them fails. I found that CrudRepository.findAll() returns entities in order which is different from run to run. The problem is caused by unpredictable results ordering from call to smembers. I know that redis's set store do not guarantee ordering, but it must be at least deterministic, i.e. no changes in data -> no changes in order.
The order is changed in lettuce code, where the results are transformed to the byte[] and then they are stored in HashSet<byte[]>. Since byte[] does not care about hashCode, this brings to random position in hashset. The code where this behavior can be observed during debugging: io.lettuce.core.output.ValueSetOutput.
Possible solution: Probably byte[] must be replaced to ByteBuffer, because ByteBuffer has overridden method hashCode (i.e. it will stay the same until there's no changes in the data)
The text was updated successfully, but these errors were encountered: