[IMP] queue_job: handle non-existing method job#940
Open
RyanTranAVB wants to merge 1 commit into
Open
Conversation
Contributor
850506f to
db9e0e7
Compare
amh-mw
suggested changes
Jul 3, 2026
Comment on lines
+83
to
+102
| except JobMethodNotFound as exc: | ||
| # In case a job's method no longer exists, we don't want the runner | ||
| # to keep re-enqueuing it. Failing it here with exceptions. We use | ||
| # raw SQL here to avoid this update being rolled back due to savepoint. | ||
| exc_name = f"{exc.__class__.__module__}.{exc.__class__.__name__}" | ||
| exc_message = str(exc) | ||
| env.cr.execute( | ||
| """ | ||
| UPDATE queue_job | ||
| SET state = 'failed', exc_name = %s, exc_message = %s, exc_info = %s | ||
| WHERE uuid = %s AND state NOT IN ('done', 'cancelled', 'failed') | ||
| """, | ||
| (exc_name, exc_message, exc_message, job_uuid), | ||
| ) | ||
| _logger.warning( | ||
| "Job %s references a non-existent method and was marked as failed", | ||
| job_uuid, | ||
| ) | ||
| if not config["test_enable"]: | ||
| env.cr.commit() |
Member
There was a problem hiding this comment.
Both the raw SQL and the ORM are using the same cursor; the same savepoint?
Member
There was a problem hiding this comment.
Perhaps job.in_temporary_env() and then ORM methods instead of raw SQL?
Author
There was a problem hiding this comment.
that's good point, I was overthinking it cause JobMethodNotFound wont cause any rollback, so it's safe using the same cursor I guess.
in_temporary_env won't work here because it's failing during loading the job as getattr fails
db9e0e7 to
af3bd94
Compare
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.
When a Job is previously created with a valid method, at any point if job not yet executed and the method is no longer valid, job runner can be stuck trying to enqueue it. This commit allows to skip these jobs with proper exception and one can clean/fix them if needed.