karlosmid
Oban jobs stuck in available state
Hi! We have following oban versions:
Oban v2.17.12
Oban.Web v2.9.7
Oban.Pro v1.4.13
Elixir:
erlang 27.0.1
elixir 1.17.2-otp-27
We have 20.8 million of messages in available state, all from same queue.
And those are stuck in that state.
Application restart does not help.
In oban web, we can not load available jobs, because we got connection error:
13:39:59.043 [error] Ch.Connection (pid<0.12344.0>) disconnected: ** (DBConnection.ConnectionError) client pid<0.94175.0> timed out because it queued and checked out the connection for longer than 15000ms
We have a lot of DBConnection errors.
How to unstuck those available jobs?
Thank you!
Marked As Solved
sorentwo
There are several possible reasons why jobs won’t run, but it seems specifically due to those timeout errors. Some immediate changes you can make to try and get the system unstuck:
-
Rebuild the indexes (
reindex table oban_jobs), force analyze (vacuum analyze oban_jobs) -
Increase the size of your RDS instance (it may be fine for normal usage, but not for a backlog of 20m jobs)
-
Manually move most of those jobs to a scheduled state to space them out. Something like this could work to reduce the
availablecount down to 100k jobs:update oban_jobs set state = 'scheduled', scheduled_at = now() + '1 hour'::interval where id < (select min(id) from oban_jobs where state = 'available') - 100000
Beyond that, here are some other suggestions once the system is moving again:
- Apply some of the options from the official scaling guide.
- Upgrade to Oban v2.19 and Pro v1.5+, primarily for the new
check_available/1implementation that optimizes the query to check for available jobs (benchmark info in the linked changelog) - Upgrade to Oban Web v2.10+ (v2.11 if possible), because it uses Oban.Met for much less database impact (especially count estimates)
Also Liked
sorentwo
There’s a Job Lifecycle guide now ![]()
sorentwo
It most likely will. I’ve replied in the other thread with more details, including some suggestions on how to monitor for that situation.
benwilson512
No, that is for jobs waiting in the queue to run.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









