lucasaas98

lucasaas98

Issues with Oban Upgrade and Telemetry Events

Hey, there!

We’re using Oban and Oban pro. We have a main worker that pulls data from 3rd parties daily.

Here’s how we define it:

defmodule Integrations.Workers.Workflow do
  use Oban.Pro.Worker,
    queue: :integrations,
    max_attempts: 5,
    unique: [
      period: :infinity,
      keys: [:integration_id, :service],
      states: [:available, :scheduled, :executing, :retryable]
    ]

This worker then triggers a Batch which uses Oban.Pro.Workers.Batch.

The idea is that we always generate a new Integration.Workflow and schedule it 24hours later. There are 3 potential outcomes:

  1. we have errors: in the ErrorHandler we schedule a Integrations.Workers.Workflow after 24 hours.
    Here’s how we attach the telemetry:
    :telemetry.attach(
      "oban-job-error",
      [:oban, :job, :exception],
      &Integrations.Telemetry.ErrorHandler.handle_event_wrapper/4,
      []
    )
  1. we have a discard that requires a reschedule: in the StopHandler we schedule a Integrations.Workers.Workflow after 24 hours.
    Here’s how we attach the telemetry:
    :telemetry.attach(
      "oban-job-stop",
      [:oban, :job, :stop],
      &Integrations.Telemetry.StopHandler.handle_event_wrapper/4,
      nil
    )
  1. all is well: In the custom callback worker for the Batch we schedule a new Integrations.Workers.Workflow for 24 hours later as well

All these scheduling is done like this:

    args
    |> Integrations.Workers.Workflow.new(
      queue: args["queue"],
      schedule_in: args["schedule_update_in"]
    )
    |> Oban.insert!()

Recently we updated Oban from 2.16.2 to 2.17.3 and Oban Pro from 1.1.4 to 1.3.0 because we wanted to use the DynamicCron plugin and use the scheduling guarantees.

This caused issues because we saw that now the ErrorHandler and StopHandler stopped being able to reschedule Integrations.Workers.Workflow workers (we have a log after the insert and it appears but the worker does not get rescheduled).

By skimming through the changelogs we noticed the ack_async had been added between said versions and by making it false the ErrorHandler and the StopHandler can now schedule the Workflows again.

We have tried in sandbox to upgrade the libs: oban from 2.17.3 to 2.17.10 and oban_pro from 1.3.0 to 1.4.9 but that has the same issue. (it also raised the db to 100% in prod but not sure if it’s related to using ack_async: false or not)

Has anyone faced a similar problem? If not, do you have tips on how we can change our flow in a way that prevents these issues?

Thanks!

Marked As Solved

sorenone

sorenone

Oban Core Team

Hey @lucasaas98,

Some people have faced a similar problem after upgrading to v1.3+ due to the async changes. Forcing the queue to disable ack_async is one way around it, but you can also disable the unique check temporarily in your telemetry hook:

args
|> Integrations.Workers.Workflow.new(
    queue: args["queue"],
    schedule_in: args["schedule_update_in"],
    unique: nil
  )
|> Oban.insert!()

The unique: nil bit is a slight hack and you’ll be able to use unique: false in the next Oban version.

On a related note, have you considered using worker hooks rather than your own telemetry handlers?

Also Liked

lucasaas98

lucasaas98

Trying the unique: nil worked!

We will try changing to the worker hooks like you mentioned as well but it will come later as it requires more refactoring.

Thank you!

Where Next?

Popular in Questions Top

skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52341 488
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement