Open WhyNotHugo opened 7 years ago
After our discussion on slack, and wanting to guarantee last-come-persists, I think we can use redis-lock
to have a blocking lock around our task creation block.
It's still possible, under some unique race conditions, that the task with the wrong ETA gets queued (though basically, it would mean that the attempt to queue them was made in the wrong order).
If the same task+args is queued twice concurrently, there might be a race condition, since the task if first queued, and then added to the backend (redis, for now).
Events can happen in this order:
A better solution would be to slightly re-write
apply_async
something like (note: this is pseudocode-ish):