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

Concurrent updates #112

Closed
vitobotta opened this issue Jun 26, 2016 · 2 comments
Closed

Concurrent updates #112

vitobotta opened this issue Jun 26, 2016 · 2 comments

Comments

@vitobotta
Copy link

Hi!

I'm currently using this gem in an app with "Tasks" where completed tasks can be moved to the top of the list when "reopened" by updating the row_order_position attribute with the :first value. This works great if, say, I manually reopen completed tasks one per time, however I also have schedules which automatically reopen certain tasks at some point in time, such as every day at midnight, and this happens asynchronously, meaning that it can easily happen that multiple tasks are moved to the top at the same time. This results in multiple tasks having the same rank/position in the list.

Do you know of any way I can avoid this and ensure each task has a unique rank even in the scenario I described? I tried things like locking and transactions with different isolation levels but with no luck (I'm using Postgres).

Thanks in advance!

@srt32
Copy link

srt32 commented Aug 23, 2017

It may not solve your problem but per the idea in #95, a unique index on the row_order column would prevent dups. Some kind of code to handle errors would be needed unless your async tasks can retry upon failure.

@brendon
Copy link
Owner

brendon commented Jun 4, 2024

You could look at an advisory lock. There is a branch with this in it. Though since I'm talking to 2016-17, this is probably not an issue for you anymore...

@brendon brendon closed this as completed Jun 4, 2024
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

No branches or pull requests

3 participants