Skip to content
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

Make rearrange_ranks resilient to race conditions #117

Closed
wants to merge 1 commit into from

Conversation

kereyroper
Copy link

In less strict isolation levels, the first or last row according to the ranking
may disappear after a rank conflict is identified, but before rearranging
occurs. Allow for approximate ordering in this case.

Serializable isolation level should still guarantee strict ordering.

undefined method `rank' for nil:NilClass

[GEM_ROOT]/gems/ranked-model-0.4.0/lib/ranked-model/ranker.rb:177 :in rearrange_ranks
[GEM_ROOT]/gems/ranked-model-0.4.0/lib/ranked-model/ranker.rb:166 :in assure_unique_position
[GEM_ROOT]/gems/ranked-model-0.4.0/lib/ranked-model/ranker.rb:61 :in handle_ranking
[GEM_ROOT]/gems/ranked-model-0.4.0/lib/ranked-model.rb:31 :in block in handle_ranking
[GEM_ROOT]/gems/ranked-model-0.4.0/lib/ranked-model.rb:30 :in each
[GEM_ROOT]/gems/ranked-model-0.4.0/lib/ranked-model.rb:30 :in handle_ranking

In less strict isolation levels, the first or last row according to the ranking
may disappear after a rank conflict is identified, but before rearranging
occurs. Allow for approximate ordering in this case.

Serializable isolation level should still guarantee strict ordering.

undefined method `rank' for nil:NilClass

[GEM_ROOT]/gems/ranked-model-0.4.0/lib/ranked-model/ranker.rb:177 :in `rearrange_ranks`
[GEM_ROOT]/gems/ranked-model-0.4.0/lib/ranked-model/ranker.rb:166 :in `assure_unique_position`
[GEM_ROOT]/gems/ranked-model-0.4.0/lib/ranked-model/ranker.rb:61 :in `handle_ranking`
[GEM_ROOT]/gems/ranked-model-0.4.0/lib/ranked-model.rb:31 :in `block in handle_ranking`
[GEM_ROOT]/gems/ranked-model-0.4.0/lib/ranked-model.rb:30 :in `each`
[GEM_ROOT]/gems/ranked-model-0.4.0/lib/ranked-model.rb:30 :in `handle_ranking`
@bf4
Copy link

bf4 commented Jul 23, 2019

probably related to #124

@brendon
Copy link
Owner

brendon commented Jul 23, 2019

Could this be rebased to see if the current version has the fault?

@fschwahn
Copy link

fschwahn commented Dec 8, 2021

This is the problem I reported in #182, but this only fixes the symptom. #179 is the better fix for this particular problem. I think this can be closed.

@brendon
Copy link
Owner

brendon commented Dec 8, 2021

Thanks for finding all these old tickets @fschwahn :) I was never keen on this nil checking so I'm glad there's a better fix :D

@brendon brendon closed this Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants