Oban job isn't retrying

Hi,

I’m working on importing Google Analytics data into Plausible Analytics. We use Oban for background jobs.

The import can be fairly flaky due to Google Analytics API timeouts. I thought I would make the job retry 5 times before reporting a failure to the user. Here’s my attempt:

When I test this locally, the job makes one attempt but never starts a second attempt. After the first attempt fails the job ends up in the following state:

%Oban.Job{attempt: 1, max_attempts: 5, state: "retryable", ...}

but it’s never picked up by Oban to actually retry.

Any ideas what might be wrong? How could I debug this further? I checked configuration and we do configure the google_analytics_imports: 1 queue for development: analytics/runtime.exs at 0d327d6dbf33b68f85f68b6bc91242f4f1f16147 · plausible/analytics · GitHub

Maybe @sorentwo could help? Sorry to ping you, just looking for some help. Don’t feel obliged to reply :slight_smile:

Also @sorentwo do you accept sponsorships? I’d like to pay for Oban but since Plausible is AGPL, we cannot use commercially licensed code (Oban Web+Pro) within our product.

Plausible is a great open-source Elixir app and we’re happy Plausible customers, I’m happy to help :smile:

Retries are essentially scheduled jobs. The stager plugin transitions jobs from scheduled or retryable to available for execution, and it also notifies the appropriate queues that they have jobs to run. It doesn’t matter which queues are configured, the stager checks all jobs purely by state.

Nine out of ten times when this happens it’s because Postgres Pub/Sub isn’t working. The other one in ten it’s because of a stuck transaction that prevents the stager from running again. I recommend upgrading to Oban v2.11.2+ because it has changes to combat either of the scenarios I shared:

Thanks for asking. We don’t have a pure sponsorship mechanism, but you’re welcome to support the project with a Web/Pro license and not use the packages :smile:

2 Likes

Thanks a ton @sorentwo ! I managed to get retries working by upgrading to v2.11 and including the Stager plugin in our config.