-
Notifications
You must be signed in to change notification settings - Fork 195
Open
Description
I have the following job. It must only be attempted once.
class RunPortalAgent < Que::Job
self.maximum_retry_count = 0
def run(session_id)
session = Portal::Session.with_pk(session_id)
if session.present?
# Code that can raise error on failure
end
destroy
end
end
When this code fails, the following row is added in the database. Note the absence of last_error_message/last_error_backtrace.
{
"priority": 100,
"run_at": "2025-10-13 14:04:25.785659+02",
"id": 1,
"job_class": "RunPortalAgent",
"error_count": 1,
"last_error_message": null,
"queue": "default",
"last_error_backtrace": null,
"finished_at": null,
"expired_at": "2025-10-13 14:04:25.899913+02",
"args": [
"5d4296f2-2891-445f-ad95-6d379b332e11"
],
"data": {
},
"job_schema_version": 2,
"kwargs": {
}
}
It seems that que incorrectly only saves the error if it is going to retry the job?
See:
Lines 155 to 171 in 17fb2c3
| if max_retry_count && error_count > max_retry_count | |
| Que.execute :expire_job, [job.fetch(:id)] | |
| else | |
| delay = | |
| job_class. | |
| resolve_que_setting( | |
| :retry_interval, | |
| error_count, | |
| ) | |
| Que.execute :set_error, [ | |
| delay, | |
| "#{error.class}: #{error.message}".slice(0, 500), | |
| (error.backtrace || []).join("\n").slice(0, 10000), | |
| job.fetch(:id), | |
| ] | |
| end |
To me it would seem logical to always save the error on failure, regardless whether the job will be expired or retried.
Metadata
Metadata
Assignees
Labels
No labels