Repository navigation
fix(admin-jobs): count a job's own run in its attempts - #70
Merged
Merged
Conversation
Issue #61. A job that ran and failed, is running, or finished reads "Attempts 0", and so does a failed job an admin retried, once it has run again. The specs cover every state the page shows: queued, waiting, scheduled, running, failed, finished, retried by an admin, and retried by the job's own retry_on (run through the queue's claimed execution). They fail until the fix that follows. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Issue #61. The job page read the "executions" value in the job's stored Active Job envelope. Active Job raises it in memory when the job runs (ActiveJob::Execution#perform_now) and it reaches the queue only when retry_on queues the job again, as a new row; so a row's stored value is the runs before it was queued, and a job that ran once and failed read "Attempts 0". Solid Queue also sets it back to 0 when a failed job is retried (FailedExecution#retry -> Job#reset_execution_counters), which leaves no record of the earlier runs in the queue's tables. The entry now adds the row's own run when it is running, failed or finished, and the page labels the fact "Attempts since queued", which is what the queue's records can say: the count starts again when an admin's retry queues the job again. No storage, and nothing written to the queue's rows. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Issue #61. The coordinator ruled on option 1 of four (count the row's own run and relabel; remove the row; write a running total into the queue's row on retry; add storage for admin retries): no storage and no writes into the queue's rows, because Solid Queue resets executions on FailedExecution#retry, so its tables cannot give a total across an admin's retry. The maintainer is to confirm the label "Attempts since queued" at PR review. AC-6.5's "attempts (executions)" is reworded to match, the spec goes to 1.1.3, and the page contract follows. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…d again A worker that shuts down gracefully releases its claimed jobs (SolidQueue::ClaimedExecution#release, solid_queue 1.7.0): the job gets a ready execution again and its stored executions stay as they were. The page therefore reads 1, 0, 1 for a job started twice. This is a limit of the queue's records; the example states what the code does (issue #61). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
"Since it was queued" was false for a row a retry_on retry queues: that row is queued after the runs it counts. The comment now covers the job's own retries, an admin's retry and a graceful shutdown. Comment only; the computation is unchanged (issue #61). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The count carries across the job's own (retry_on) retries, includes a run in progress, starts again when an admin retries a failed job, and leaves out a run cut short by a graceful shutdown once the job is back in the queue. The contract says the same. The changelog row no longer says the label awaits confirmation: the label "Attempts since queued" stays as ruled for issue #61 and the pull request asks the question. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The dated observation and its screenshots stay as they are. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
A job's page at
/admin/jobs/:idnow counts the job's own run, so a job that failed reads 1 rather than "Attempts 0". The row is labelled "Attempts since queued".Closes #61
Cause
BackgroundJobs::Entry#attemptsreturnedexecutionsfrom the job's stored Active Job envelope. Two things make that the wrong number:executionsonly in memory inperform_now(activejob 8.1.4execution.rb:47). It is stored only on the new row aretry_onretry inserts, so a row's stored value is the runs before that row was queued and never its own run.FailedExecution#retry→Job#reset_execution_counters(solid_queue 1.7.0job/retryable.rb:33), which sets it back to 0 on the same row. After that the row is identical to a freshly queued one.So the queue's tables can't give a total across an admin retry.
What changed
Entry#attemptsis the stored executions plus one when the job is running, failed or finished. No new storage, and nothing is written to the queue's rows (ADR 0014).contracts/api.mdand the code comment say how the count behaves (spec 015 version 1.1.3). The research note that recorded "Attempts 0" points here.retry_onretriesDecision for you: the label
I chose the no-storage option and the label "Attempts since queued" during the work. The reviewer found that no single reading of "queued" is true in every row beside the page's own "Queued" time:
created_at.retry_onrow reads 1 although nothing has run since that row was queued.Alternatives: keep "Attempts" and let AC-6.5 carry the caveats; remove the row; or add storage to count admin retries (a migration, and the primary and queue databases are separate files). Changing the label is one line in
app/views/admin/jobs/show.html.erbplus the spec wording.Verification
bin/ci: passed. RSpec 1226 examples, 0 failures, 1 pending (the art agreement spec, unrelated).retry_onexamples run jobs through Solid Queue's realClaimedExecution#perform. The graceful-shutdown example is a characterization that passed on first run; it fails under a mutation ofattempts.Notes
retry_onchain shows as Finished with 1 attempt although it raised; that is how Solid Queue records it and is unchanged.docs/roadmap.mdstill lists A retried job shows "Attempts 0" #61.🤖 Generated with Claude Code