seomoz/qless — pull request #62 by myronmarston (2012-12-07 00:48:58+00:00)
Title: Failing spec demonstrating a bug with recurring jobs of diff priority

This is a bug we ran into due to the changes in https://github.com/seomoz/qless-core/commit/bea9915f7aea673b47fca37ab2f68b3b313a6b46. It's very subtle, so an example will demonstrate best:

* Recurring jobs `high_pri` and `low_pri` are enqueued with the same recurrence schedule, but different priorities.
* Previously, `queue.pop` would always pop a `high_pri` job before a `low_pri` job, as it should.
* With the change in that commit, `queue.pop` only spawns 1 job from the recurring queue to the work queue. Given that the recurring queue is a sorted set scored by a timestamp indicating "when to spawn a job next", there's no guarantee about which of the two jobs will be the first one returned by the limited`zrangebyscore` command used in `pop`. Thus, the `low_pri` job can be moved to the work queue first, and be popped first.

I'm not sure what the fix should be for this but I came up with a failing spec.

Let me know if you have any questions, @dlecocq.