rq-scheduler
rq-scheduler copied to clipboard
Lock can timeout when enqueue_jobs() execution is longer than expected
Hi.
It is possible that scheduler's lock can timeout when enqueue_jobs()
execution takes longer than _interval
+ 10 secs. I'm using interval=5
, so max time for enqueue_jobs()
is 15 secs. This is too low for long jobs table or connection/server slowdowns. When lock is releasing due to timeout, the other instances of rq-scheduler are acquiring a new lock and do their job in parallel.
The one of the possible solution is to use https://github.com/ionelmc/python-redis-lock with autorenewal=True
to acquire a lock, which will be renewed during long call by separate thread.
Yeah, this can be problematic if the scheduler is running on a low interval. I think we can easily avoid this by choosing a mininum lock interval of 60. Mind opening a PR for this?