mattei
Hi all, big Elixir fan (and newbie!) dropping by to ask something that has been puzzling me for a bit.
I’m building an app that relies on Oban for job processing. However, some jobs are getting killed/crashing with obscure errors by the BEAM.
These are the strange behaviors:
-
Oban job gets killed. The Oban job is simple, it only does an HTTPoison request.
-
Requests/responses seem to get stalled. HTTP requests take too long/forever, although the actual time elapsed doesn’t reflect in the response time metric in terminal.
Request gets stalled early in the plugs process, then after a few second resumes:
When it happens (all local, not production):
- High request rate – sending tons of requests, Oban job inserts from Postman into the API endpoint
- Suspected high memory pressure – although I doubt it’s OOM, because I’ve looked at activity monitor and sometimes it happens, even in the green.
- Randomly – sometimes I’m only sending a one off request
Here are some suspicions:
- Too many queries being sent, Postgres stalling.
- Out of memory/low resource behavior, but I thought BEAM handled this better.
- Oban job taking too long, although it’d be a TimeoutError, not a Killed.
- Infinite recursion somewhere, although I feel that’d also be a TimeoutError from Oban.
- HTTPoison bug, the process gets killed.
- Memory leak.
I have no leads other than these error messages and strange behavior.
Where would I start to debug this problem? How would I prove any of these theories? I’m new to the BEAM and it’s very different from a traditional language.
Trending in Questions
Other Trending Topics
Latest Phoenix Threads
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
- #blog-post
- #phoenix_html
- #iex
- #ai
- #graphql
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex












Showing Posts 1 to 10- Show Best Posts
- Show All Posts (oldest first)
- Show All Posts (newest first)
lud
Your process receives and :EXIT message from another process that is linked to the former.
Do you start a process from your job process with a
SomeModule.start_linkorspawn_linkcall? The process with pid <0.13246.0> was killed and as it was linked to your own process, your process exited with that same reason.You may create a test and directly call your
Job.performfunction repeatedly, without starting oban. This will be easier to get a proper stacktrace.emoragaf
I’m throwing a dart in the dark here, but I’ve been bitte by HttPoison/hackney pools before, where if the request crashes it doesn’t release the connection, starving the pool in a short time.
Try setting
pool: falseand see if that helps maybe?mattei
Hey, thanks for the idea. I never thought of this – this is much easier to test in isolation.
I’ve performed a simple load test, and everything I can throw at it seems to work. The job executes well. I’ll continue testing the worker in isolation and report back – I’m hoping to get a better stack trace than whan Oban provides.
mattei
I figured it could be caused by HTTPoison pools – will absolutely try this, as I have no clue where the process is getting sent a :killed.
Just found that pools limit the amount of concurrent connections you can execute, will disable them. This could be the problem: too many Oban jobs are executing in parallel and the pool gets killed?
emoragaf
normally you would wait for a connection to become available, but when you have the issue of having the connections not being released back into the pool you basically loose capacity silently until things blow up.
The worst thing is that since it’s very easy to just leave the :default pool, you can have totally unrelated parts of your app (that also use the default pool) causing this issue.
This kind of thing could indeed be the root cause of pool starvation, to the point where you have your jobs waiting forever for a connection that is never going to be put back into the pool
mattei
I’ve disabled the connection pool and wrote a small testing Mix script to load test the behavior. I’m seeing no :killed yet, but will continue testing over the following days under many conditions (including starving the system of memory).
Reporting back in a bit.
mattei
I’ll continue testing over the next couple of days. I got some errors, but because the system ran out of file descriptors (I bombed the system with requests). I also saw a Killed error somewhere, so I suspect the problem persists.
I will continue testing in different system conditions, such as high memory usage and long uptime (lots of hot reloads from Phoenix, for example) and report back. I’m still wondering what caused the problem, or if I can prove the connection pooling caused it definitively.
I think I’ve seen the problem more with long-running instances of mix phx.server, which include closing the laptop lots and leaving the process on for days on end.
cmo
You’ll probably see the other error with those on.
lud
This is not concurrent. Your other snippet with
Task.Supervisor.asyncis the way to go. Now, it can be actually pretty fast. What I would do is to simulate load by adding a sleep(1 second) in the server that responds athttp://localhost:4000/v1/events/.You said that you do not see the problem in tests. Does the problem still exists when using Oban?
mattei
The problem is primarily when using Oban, yes.
I will add a Process.sleep at the controller and the Oban job to simulate load
EDIT: Okay, so what ends up happening under the load script is that the server locks up and requests don’t go through. The error persisted.
I’m so confused. I think I found how to replicate it. This only happens when the laptop goes to sleep and comes back. I restarted the process and it’s processing jobs, handling requests like normal without Phoenix locking up.
Odd state bug? I’m worried this might end up happening in production with long-running instances.