Jobs can be processed and left in the `wait` state
Created by: bradvogel
@manast Following the discussion in https://github.com/OptimalBits/bull/pull/359, I found a hazard that I think we should address before releasing a new version: a job can be processed an still left in wait. Here's how:
Time | Process A | Process B |
---|---|---|
1 | In the regular Bull run loop of Process A, getNextJob moves a job from wait to active
|
|
2 | In Process B, moveUnlockedJobsToWait happens to run and pick up the job in step 1, and moves it back to wait |
|
3 | Process A gets lock on the job (that is now in 'wait') and begins to process it |
If there is no other process around to move the job back to active
then Process A will complete the job and leave it in wait
. This can lead to a data inconsistency.