Comments (10)
Hi @unflxw
I believe the issue might lie in all those millions of Ecto queries being instrumented. Could you try running this job with the instrument_ecto: false configuration option, and seeing if the issue persists?
There's no memory leak when using the instrument_ecto: false
configuration
If that does fix the issue, adding Appsignal.Tracer.ignore() at the top of the Oban worker's perform method should also fix it, without removing Ecto instrumentation for the rest of the application.
Thank you, this is a good workaround for us for now
from appsignal-elixir.
Or maybe a better Appsignal behavior would be to detect an unusually high amount of spans under a root trace, and log a warning or error when it happens, and stop adding more after that to avoid crashing the server 🤔
from appsignal-elixir.
This is on current Elixir (1.16.0) and Erlang (26.2.1)
from appsignal-elixir.
The memory leak still happens if I try to ignore the worker with ignore_actions: ["Worker#perform"]
from appsignal-elixir.
Hi @michallepicki!
Ignoring through the ignore_actions
configuration option takes place "after the fact" -- the action is instrumented, then ignored. So it makes sense that the configuration option wouldn't help with the memory costs of instrumenting it.
I believe the issue might lie in all those millions of Ecto queries being instrumented. Could you try running this job with the instrument_ecto: false
configuration option, and seeing if the issue persists?
If that does fix the issue, adding Appsignal.Tracer.ignore()
at the top of the Oban worker's perform
method should also fix it, without removing Ecto instrumentation for the rest of the application.
from appsignal-elixir.
Perfect! Thank you for letting us know. Feel free to reach out here, or at [email protected], if you run into any other issues.
from appsignal-elixir.
Sorry, I don't understand why you closed the issue? I think this is a valid usage of Oban and Ecto, and I'm surprised that it's leaking memory (this is a big background job, but ideally we'd like to have the job instrumented anyway)
from appsignal-elixir.
And there's a second slightly overlapping issue here as well, that canceling an Oban job is not handled properly and the VM is stuck with extra memory usage leaked
from appsignal-elixir.
@michallepicki I have created #914 about the issue when the Oban job is cancelled via Oban Web, after the details you provided over email clarified the issue. Thank you!
As you described over email, AppSignal is not leaking memory: rather, it is using a lot of memory, and freeing it after the job is done, with an additional delay on the cancellation scenario. To instrument a transaction containing a million Ecto queries, we must temporarily keep information about a million Ecto queries in memory. We have some improvements in the works that will alleviate the memory load, but at the end of the day, monitoring necessarily trades system resources for operational visibility.
Certainly, this is a valid usage of Ecto, but that doesn't mean that it's meaningful to instrument it in this way. Our automatic instrumentation makes specific assumptions which have trade-offs. It works well for instrumenting endpoints that perform a small set of operations, and it doesn't work so well for instrumenting batch jobs that perform a large amount of operations.
Ultimately, AppSignal can't display millions of events in its event timeline anyway, so I would suggest instrumenting this differently. An option could be to disable the Ecto instrumentation, and instead using custom instrumentation to instrument the whole Ecto transaction as a single event. This allows you to keep track of how long the Ecto transaction is taking as a whole, without polluting the transaction with millions of repetitive events.
from appsignal-elixir.
Thank you for writing this up, I hope future improvements will make it possible to use Appsignal for instrumenting batch jobs that perform a large amount of operations. I imagine more state would need to be tracked on your servers, but it may be worth it. In the meantime, do you think there could be some warnings added to the Elixir Appsignal documentation about this, mentioning the Appsignal.Tracer.ignore()
workaround? Or maybe this behavior is documented somewhere already and I missed it?
from appsignal-elixir.
Related Issues (20)
- Custom params and session data is overwritten by Plug integration HOT 3
- How to filter out events programmatically? HOT 13
- Implement a way to set span name and attributes without overriding
- AppSignal doesn't build with the new linker in Xcode 15 HOT 8
- Drop support for unmaintained Elixir/Erlang versions
- Provide logging feature through a logger handler HOT 1
- Collect Ecto stacktraces HOT 9
- Are calls to `add_distribution_value` synchronous or asynchronous? Can they raise errors? HOT 2
- Neon startup causes errors to be sent to AppSignal HOT 2
- (Mox) testing guidelines? HOT 3
- Oban "Insert job" should not be a root span HOT 1
- AppSignal causes Phoenix to seg fault when a request is received on MacOS 13.6 HOT 12
- Expose a way to clone the Tracer stack for a process HOT 2
- Allow for additional context to be added to Tesla calls
- Jobs cancelled via Oban Web are not properly closed
- `Logger.error` does not log AppSignal Error HOT 2
- Clickable stack traces to directly jump into the source HOT 1
- Allow setting per-process metadata to unhandled exceptions HOT 3
- Consider sharing exception "blame" information to aid debugging HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from appsignal-elixir.