Some periodic jobs with repeat counts never go away
If I start a periodic job with a repetition count of 5, and from within each invocation of that job I submit a single non-periodic job to another worker, the parent job's repetition count never makes it all the way to zero - the repetition count is effectively ignored, making the job last forever. Printing the repeat count within enqueue_job, I can see that it decrements a few times, and then stops going down before reaching zero.
However, if I start a periodic job with a repetition count of 5, and I don't submit another job from within it, the repetition count of the periodic job decrements as one would expect, and the job's periodic evaluation is eventually finished.
I'm working on getting permission to share a test program that highlights the issue.
Here's some test code that replicates the problem:
http://stromberg.dnsalias.org/~strombrg/rq-scheduler/
HTH
I'm afraid I couldn't reproduce the issue. The example you gave is kind of complex so I created my own tests using the bare minimum. In this gist you'll see that the job gets enqueued exactly three times.
https://gist.github.com/selwin/515049017c1e87112959
Please check out my gist, is there anything I missed?