Skip to content

Conversation

@rosa
Copy link
Member

@rosa rosa commented Jul 21, 2025

*(Even though this will be overwritten by Active Job when called through perform_later.)

This is necessary for recurring tasks, where we run the enqueue callbacks manually and call Job.enqueue. We rely on successfully_enqueued? to know whether we need to record the recurring execution. We were setting that no matter what after calling Job.enqueue because we were relying on that to raise (which would be the case for Active Record errors).

In the case of discarding it because of concurrency controls, the job is simply not persisted but no error is raised, which means we were trying to record a recurring execution without a persisted job, which would raise.

Fixes #598

Even though this will be overwritten by Active Job when called through
`perform_later`.

This is necessary for recurring tasks, where we run the `enqueue`
callbacks manually and call `Job.enqueue`. We rely on `successfully_enqueued?`
to know whether we need to record the recurring execution. We were setting
that no matter what after calling `Job.enqueue` because we were relying on
that to raise (which would be the case for Active Record errors).

In the case of discarding it because of concurrency controls, the job is simply
not persisted but no error is raised, which means we were trying to
record a recurring execution without a persisted job, which would raise.

Fixes #598
@rosa rosa merged commit be1a5bc into main Jul 21, 2025
128 of 129 checks passed
@rosa rosa deleted the handle-not-enqueued-job-without-raising branch July 21, 2025 19:41
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.

A recurring job that has on_conflict: :discard AND triggers conflict condition generates a NotNullViolation

2 participants