nono.31

nono.31

Oban - Caching Ecto Statements ETS Table memory leak -> OOM

Hello

  • We’re using Oban.Pro 1.14
  • we have 23 queues
  • we use partitioning
  • we use uniqueness
  • we use local limits
  • we use global limits
  • we use rate limits
  • we use DynamicCron heavily (1800+ cron entries)
  • we have multiple nodes
  • we process millions of jobs a day

We are having an issue where our Ecto.Repo ETS table is slowly growing until we get an OOM (currently reaching our limit of 8GB).

Our Repo is mainly used for Oban.

I am trying to dig deeper into this to try to isolate where this can come from, but it seems related to internals of Oban :sweat_smile:

Here we are using 105MB after a few hours:

Some of the ETS table details at this point:

  • has 16178 references to the oban_jobs table
  • has 12 reference to name: "ecto_*

You can find a small portion of it at https://gist.githubusercontent.com/mathieurousseau/6e6529da36bc09927fb9227ed4acbebf/raw/72f46766b6acf9aede031d820e70df59577afd10/gistfile1.txt

Something I have isolated:

  • The leader ecto ets table does not grow if it does not process any jobs (probably only taking care of main Oban business and the Cron)

What can I provide to help with this investigation?
Is there some obvious configuration that you know could mitigate this? (using prepare: :unamed on ecto configuration did not change anything)

Thanks.

Mathieu

First 10 of 23 Posts Switch mode

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

What version of Ecto are you using? I seem to recall some isssue in Ecto related to this that was fixed at one point.

dimitarvp

dimitarvp

Probably talking about this?

sorentwo

sorentwo

Oban Core Team

As indicated, this is fundamentally an Ecto issue. There are improvements in more recent versions of Pro to compensate for this issue by disabling prepared statements for highly dynamic queries.

Aside from upgrading Ecto and Pro, you could disable prepared statements for all Repo queries with prepare: :unnamed (double check the options in the Ecto docs).

nono.31

nono.31 OP

About the Ecto fix post:
You can find me saying on that post that last version of Ecto did not solve the issue for us :sweat_smile:

We tested 1.5 RC but issue remained. We are on latest Ecto and prepare: :unnamed did not work :slightly_frowning_face:

I will try to create a dummy project to reproduce this behaviour.

dimitarvp

dimitarvp

Whoops, sorry. No clue then.

sorentwo

sorentwo

Oban Core Team

That should disable prepared statement caching entirely. Are you certain you configured that for the Repo that Oban is using?

Please do. If you have a reproduction I’ll gladly investigate.

nono.31

nono.31 OP

yeah I am sure I have configured prepare: :unnamed on the Repo :slight_smile:

The catch though, I have doubled check on our deploy and:

  • prepare: :unnamed done in runtime.exs does not work

I will put it in the config.exs and test again.

nono.31

nono.31 OP

Well, that did not make any difference. I doubled check the conf was loaded and ETS table still grows :frowning:

sorentwo

sorentwo

Oban Core Team

That sounds like an issue with ecto or dbconnection itself then. Oban makes judicious use of prepare: :unnamed for frequent, variable queries, and it would be an problem if the option isn’t being respected.

nono.31

nono.31 OP

yes, that’s probably it.

I have a dummy project that I need to clean up that I will share shortly.

But here are the queries that are still being cached:

all, delete_all, update_all

Example of the largest one (141k):

Where Next?

Trending in Questions Top

jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement