Skip task setup for non-runnable Runs - #1536
Open
salasebas wants to merge 1 commit into
Open
Conversation
salasebas
marked this pull request as ready for review
August 15, 2026 23:05
gmcgibbon
reviewed
Aug 21, 2026
| with_stale_object_retry do | ||
| running! unless stopping? | ||
| reload_status if running? | ||
| running! if RUNNABLE_STATUSES.include?(status.to_sym) |
Member
There was a problem hiding this comment.
Suggested change
| running! if RUNNABLE_STATUSES.include?(status.to_sym) | |
| running! if runnable? |
Let's define a predicate for this. It is easier to read.
Contributor
Author
There was a problem hiding this comment.
Added Run#runnable?
| def before_perform | ||
| @run = arguments.first | ||
| @run.running | ||
| abort_unless_run_is_running |
Member
There was a problem hiding this comment.
Do we need to call this multiple times? Perhaps we just need the second one.
A job can remain queued after its Run is cancelled. When eventually worked, it currently downloads CSV data, builds the collection, sets started_at, and runs after_start before stopping. Claim the Run before task setup and abort when it is no longer runnable. Preserve pausing and cancelling transitions, and prevent the no-locking fallback from moving paused or completed Runs back to running. Adds Run#runnable? and regression coverage for cancelled jobs, lifecycle callbacks, races, and both locking paths.
salasebas
force-pushed
the
agent/skip-task-setup-for-non-runnable-runs
branch
from
August 25, 2026 16:26
a0904df to
cdfe46e
Compare
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 can remain queued after its Run is cancelled. When eventually worked, it currently downloads CSV data, builds the collection, sets
started_at, and runsafter_startbefore stopping.Claim the Run before task setup and abort when it is no longer runnable. Preserve pausing and cancelling transitions, and prevent the no-locking fallback from moving paused or completed Runs back to running.
Adds regression coverage for cancelled jobs, lifecycle callbacks, races, and both locking paths.
Tests:
bundle exec rake testandbundle exec rubocop --no-parallel.