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

procrastinate_fetch_job can end up being slow #1242

Open
ewjoachim opened this issue Nov 20, 2024 · 3 comments · May be fixed by #1241
Open

procrastinate_fetch_job can end up being slow #1242

ewjoachim opened this issue Nov 20, 2024 · 3 comments · May be fixed by #1241

Comments

@ewjoachim
Copy link
Member

Following discussion from Discord starting here and below, it seems we could vastly improve the performance of procrastinate_fetch_job.

The following query plan was posted.

@ewjoachim ewjoachim linked a pull request Nov 20, 2024 that will close this issue
10 tasks
@joaquimds
Copy link

Woah, someone with the same name (pretty much) as me has already raised the issue I was about to raise?

Re: the PR, why is it necessary to make the change in manager.py? It looks to me that the existing query will already fallback to a job where jobs.lock IS NULL.

@ewjoachim
Copy link
Member Author

Welcome to the club of Joa(qu|ch)im procrastinators !

Btw, as the repo maintainer, I opened the issue tracking the discussion but @TheNeedForSleep is the one deserving praise for this.

Feel free to chime in in the PR rather than here, the author is more likely to react.

As to myself, I'm sorry but I was much to busy lately to start evaluating this. That said, thank you for your interest and welcome around !

@TheNeedForSleep
Copy link

If two or more workers fetch a job with the same lock one of them will have a unique constraint violation on the update part.
If it fails to update due to unique constraint it will retry upto 3 times with fuzzy delay to avoid race condition.

If the worker still fails to get a job it will just get a job where no unique constraint violation can occur e.g. a job without a lock.

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

Successfully merging a pull request may close this issue.

3 participants