Skip to content

Include the error in fail_many_claimed events and document recovery - #779

Open
wintan1418 wants to merge 1 commit into
rails:mainfrom
wintan1418:expose-error-on-fail-many-claimed
Open

Include the error in fail_many_claimed events and document recovery#779
wintan1418 wants to merge 1 commit into
rails:mainfrom
wintan1418:expose-error-on-fail-many-claimed

Conversation

@wintan1418

Copy link
Copy Markdown
Contributor

Closes #591

Approach

Following the discussion in #591: not automatic retries (poison-pill risk, as @rosa pointed out), but the hook @nhorton asked for, so applications that know their jobs are idempotent can implement their own recovery policy.

It turns out most of the machinery already exists: ClaimedExecution.fail_all_with — the path that marks in-flight jobs as failed when their process is pruned or a crashed fork is reaped — already emits fail_many_claimed.solid_queue with the affected job_ids and process_ids. What was missing was the error in the payload, so subscribers couldn't distinguish a prune (ProcessPrunedError) from other mass failures, and any documentation that this hook exists.

This PR:

  • Adds error to the fail_many_claimed payload (and to its log line, using the existing formatted_error convention).
  • Extends the existing instrumentation test to assert the error is included.
  • Documents the recovery pattern in the README under "Failed jobs and retries": why these jobs aren't retried automatically, and a subscriber example that re-enqueues via FailedExecution#retry with an explicit note that the application must bring its own safeguard against retry loops.

No new machinery, no behavior change for anyone not subscribing to the event.

Testing

Instrumentation and log subscriber test files green on MySQL.

Jobs running on a process that dies without a clean shutdown are marked
as failed with ProcessPrunedError (or ProcessExitError when the
supervisor reaps a crashed fork) via ClaimedExecution.fail_all_with,
which already emits a fail_many_claimed event with the affected job and
process ids. The error itself wasn't part of the payload though, so
subscribers couldn't tell these mass failures apart from each other.

Add the error to the event payload and to the log line, and document how
to subscribe to the event to implement a custom recovery policy for
these jobs, including why Solid Queue doesn't retry them automatically.

Closes rails#591
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.

Need to retry jobs that died with ProcessPrunedError

1 participant