rq-scheduler icon indicating copy to clipboard operation
rq-scheduler copied to clipboard

Lock can timeout when enqueue_jobs() execution is longer than expected

Open marcinn opened this issue 4 years ago • 1 comments

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.

marcinn avatar Apr 14 '20 11:04 marcinn

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?

selwin avatar Jul 10 '20 01:07 selwin