Created by: bdentino
First contribution, so apologies if I've missed anything or stepped on any project standards - happy to make updates to the PR as necessary.
I noticed some strange behavior in one of my applications where jobs were not being processed according to priority. I could reproduce reliably in production, but not in a new staging environment so I dug into the repo and checked some of the keys in Redis. Long story short, I found out that whenever I run the cleanJobsInSet
script on the waiting jobs it causes the priority set to go wildly out of sync with the jobs list because these jobs aren't being removed, and I believe this was causing new jobs to get inserted into the jobs list at strange indexes. I have a script running in production that periodically cleans up the different states, and once I re-synced by resetting the priority key and removing all jobs the problem was gone.
This fix simply updates the cleanJobsInSet
script to remove each job from the priority set if present.
I don't know when the clean feature was introduced, but I wonder if this could have been causing the OPs issues in #733 (closed)?