Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace job state on conflict #935

Closed
sezaru opened this issue Aug 1, 2023 · 1 comment
Closed

Replace job state on conflict #935

sezaru opened this issue Aug 1, 2023 · 1 comment
Labels
area:oss Related to Oban OSS closed:wontfix This will not be worked on kind:enhancement New feature or request

Comments

@sezaru
Copy link

sezaru commented Aug 1, 2023

Is your feature request related to a problem? Please describe.

Oban allows you to set which fields to change when there is a conflict and the job is in the discarded state but it doesn't allow to also change the job status, meaning that, for a discarded job, you can replace the fields with the new job on conflict, but the job will remain in the discarded state instead of changing it to something like scheduled.

Describe the Solution You'd Like

To be honest, I was expecting that a discarded job that had a conflict would just go back to the scheduled state after the conflict fields are replaced.

At least, I would expect an option like retry_on_conflict or something like that to allow this scenario.

@sorentwo
Copy link
Member

sorentwo commented Aug 1, 2023

Jobs with a discarded or cancelled state aren't considered for uniqueness, insertion will always work without a conflict. It's best to be highly targeted in which states/fields you'll update anyhow.

If you've explicitly set unique states to include discarded and you want to retry on conflict, you'll need to write a little wrapper to handle it:

changeset = Worker.new(some_args)

with {:ok, %{conflict?: true, state: "discarded"}} <- Oban.insert(changeset) do
  some_args
  |> Worker.new(unique: [states: [:available]])
  |> Oban.insert()
end

@sorentwo sorentwo added kind:enhancement New feature or request closed:wontfix This will not be worked on area:oss Related to Oban OSS labels Aug 1, 2023
@sorentwo sorentwo closed this as not planned Won't fix, can't repro, duplicate, stale Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:oss Related to Oban OSS closed:wontfix This will not be worked on kind:enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants