Skip to content

Stop workers when job finalization fails - #768

Open
rafael-pissardo wants to merge 2 commits into
rails:mainfrom
rafael-pissardo:fix/748-claimed-execution-stuck-on-finished-failure
Open

Stop workers when job finalization fails#768
rafael-pissardo wants to merge 2 commits into
rails:mainfrom
rafael-pissardo:fix/748-claimed-execution-stuck-on-finished-failure

Conversation

@rafael-pissardo

@rafael-pissardo rafael-pissardo commented Jul 24, 2026

Copy link
Copy Markdown

Summary

  • wrap finalization failures while a claimed execution is still present in a dedicated error
  • stop the owning worker after that unrecoverable error so shutdown releases the claim for retry
  • keep workers running after ordinary job failures and avoid joining from a pool thread

Fixes #748.

Test plan

  • TARGET_DB=sqlite bundle exec ruby -Itest test/unit/worker_test.rb
  • TARGET_DB=sqlite bundle exec ruby -Itest test/models/solid_queue/claimed_execution_test.rb
  • TARGET_DB=sqlite bundle exec ruby -Itest test/integration/jobs_lifecycle_test.rb
  • RuboCop on changed Ruby files

@rafael-pissardo
rafael-pissardo force-pushed the fix/748-claimed-execution-stuck-on-finished-failure branch 2 times, most recently from db4a139 to d903a36 Compare July 24, 2026 20:03
Prevent claimed executions from remaining stuck after transient database errors by terminating the owning worker so shutdown releases the claim.
@rosa
rosa force-pushed the fix/748-claimed-execution-stuck-on-finished-failure branch 3 times, most recently from 1e36cfd to 407aff7 Compare August 22, 2026 18:57
Wrap only the two finalization calls in the guard that escalates
still-claimed failures to FinalizationError, and inline the result
handling back into perform. The job's own error re-raise no longer
passes through the rescue, which spared it a redundant still-claimed
check on every ordinarily failing job, and the clause guarding against
re-wrapping an already-wrapped error becomes unnecessary. The guard is
called finalizing, leaving finalize to the existing single-finalization
machinery.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@rosa
rosa force-pushed the fix/748-claimed-execution-stuck-on-finished-failure branch from 407aff7 to 594cfdb Compare August 22, 2026 19:09
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.

ClaimedExecution can be stuck in claimed state forever when #finished raises

2 participants