Repository navigation
[19.0][FIX] queue_job: wake the job runner up on stop - #1011
Open
HoloborodkoBohdan wants to merge 1 commit into
Open
HoloborodkoBohdan wants to merge 1 commit into
HoloborodkoBohdan wants to merge 1 commit into
Conversation
A runner that lost the master election, or hit an error, slept ERROR_RECOVERY_DELAY with time.sleep, and the start delay slept START_DELAY the same way. stop() could not interrupt either, and the server joins the runner thread on shutdown, so the whole process waited up to 5 seconds. On hosts that kill a process a few seconds after asking it to stop, a process whose runner was not the master was killed instead of exiting. Both delays now wait on an event that stop() sets.
Contributor
amh-mw
approved these changes
Oct 15, 2026
amh-mw
left a comment
Member
There was a problem hiding this comment.
Code review only, LGTM.
Would you kindly prefix the issue title with [19.0]? It will make it easier to keep things organized when this fix is ported to other branches.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A runner that lost the master election (or hit an error) waits
ERROR_RECOVERY_DELAYwithtime.sleep, and the runner thread and worker waitSTART_DELAYthe same way before starting.stop()cannot interrupt either, and since the server joins the runner thread on shutdown, the whole process waits up to 5 seconds before it exits.With several workers each starting a runner, only one wins the election and the others spend most of their time in that sleep. On hosts that send SIGKILL a few seconds after asking a process to stop (odoo.sh allows about 5 s), those processes get killed instead of exiting: on one production day, 141 of 538 worker shutdowns ended in SIGKILL, all of them during this sleep.
Both delays now wait on a
threading.Eventthatstop()sets.Measured locally (Odoo 19, threaded server, master lock held by another session, SIGTERM at different points of the 5 s cycle): from "graceful stop requested" to "stopped" took 0.7-4.4 s before, about 1 ms after.
Two tests added; both fail on the current 19.0 branch