Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Scheduler Immediately Upon rqworker --with-scheduler #2084

Open
orokusaki opened this issue May 2, 2024 · 1 comment
Open

Run Scheduler Immediately Upon rqworker --with-scheduler #2084

orokusaki opened this issue May 2, 2024 · 1 comment

Comments

@orokusaki
Copy link
Contributor

When running rqworker --with-scheduler (django-rq), after I restart the server (e.g., during deploy), I notice that it takes a while before scheduled tasks are enqueued - the docs state, "Idle schedulers will periodically (every 15 minutes) check whether the queues they’re responsible for have active schedulers." Is this the cause of the delay we see (the delay seems to range from a few minutes to 10 minutes)? When starting via --with-scheduler is there a way to tell the system to start running the scheduler immediately, so that queued up tasks that come due are run without that multi-minute delay?

P.S. @selwin - pardon the duplicate notification - I started to piggyback this on a scheduler-related issue, to avoid making a new issue, but immediately realized I was co-opting the other issue's subject by doing so.

@selwin
Copy link
Collaborator

selwin commented May 26, 2024

When a worker() first starts, it already tries to acquire scheduler locks so in your case, the lock was probably still active when your workers started.

Worker will periodically try to acquire locks during run_maintenance_tasks() here: https://github.com/rq/rq/blob/master/rq/worker.py#L922

One way we can make the delay in acquiring schedulers shorter is by reducing the maintenance task interval to 5 minutes (it was initially 15 minutes and now 10 minutes).

You can also manually pass in maintenance_interval argument to Worker class. https://github.com/rq/rq/blob/master/rq/worker.py#L143

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants