Skip to content

Conversation

@sbidoul
Copy link
Member

@sbidoul sbidoul commented Dec 11, 2025

Do not wait for locks and start jobs that are not in the expected state.

In a nutshell this PR replaces two SELECT FOR UPDATE by SELECT FOR UPDATE SKIP LOCKED. This is because if the job to run is already locked or not in the expected state there is no need to wait: it means the job is being executed by another worker already.

Also since there is commit between the check that the job is in enqueued state and set started, and the actual start of execution, there was window there for two workers to start the same job in some rare situations. This PR should avoid this case.

Maybe fixes #858

Do not wait for locks and start jobs that are not in the expected state.
@OCA-git-bot
Copy link
Contributor

Hi @guewen,
some modules you are maintaining are being modified, check this out!

@sbidoul
Copy link
Member Author

sbidoul commented Dec 11, 2025

@thomaspaulb if you have a reproducer, for #858 you may want to test this, possibly in combination with #853

@sbidoul sbidoul marked this pull request as draft December 11, 2025 13:00
@sbidoul
Copy link
Member Author

sbidoul commented Dec 11, 2025

BTW, for readability, I think the first part of _try_perform_job (until job.lock()) should be extracted from that function. That would make the flow easier to understand.

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 this pull request may close these issues.

After requeueing a job, first run often fails to update date_done with concurrent error

2 participants