Repository navigation
[IMP] queue_job: handle non-existing method job - #940
RyanTranAVB wants to merge 1 commit into
Conversation
850506f to
db9e0e7
Compare
| 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() |
There was a problem hiding this comment.
Both the raw SQL and the ORM are using the same cursor; the same savepoint?
There was a problem hiding this comment.
Perhaps job.in_temporary_env() and then ORM methods instead of raw SQL?
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
|
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
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.