Create "discrete" good_job_executions
table to separate Job records from Execution records and have a 1-to-1 correspondence between good_jobs
records and Active Job jobs
#928
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.
On the path to #831, which requires having a single row per job to lock, whereas currently GoodJob overloads a single table to contain both Execution and Job records, which leads to multiple rows with the same
active_job_id
.This PR provides a backwards-compatible/minor-releasable change by adding a new
good_job_executions
table corresponding toGoodJob::DiscreteExecutions
model, along with a booleanis_discrete
column on Jobs/Executions. Once the migration is run, subsequently created jobs will bediscrete
, and they will use the new table. Old, non-discrete jobs will continue to run with multiple executions.discrete
Job records are updated in place with the most recent attributes after retries. DiscreteExecutions/good_job_executions
are used to track historical changes in job attributes (#271)Because
is_discrete
is a nice boolean for adding in additional behavior, a few other minor changes:id
is the same as theactive_job_id
. This is a nice alignment with Active Job.scheduled_at
value. If it is not actually scheduled for the future, it should be identical to thecreated_at
value. This should help make the fetch-and-lock query a little simpler while still being able to differentiate between jobs that are intended to run immediately or are actually scheduled.When this gets to the
v3.99
release, it will be necessary to ensure that all unfinished jobs arediscrete
so thatv4.0
can safely remove the backwards compatible code-paths. I'm imagining some kind of "Healthcheck" to peep that out, but that's not implemented here.serialized_params
, which is necessary becauseDiscreteExecutions
are not created until the job is performed, which is different currently thanExecutions
.