Add memory leak scenario to email service#2481
Add memory leak scenario to email service#2481julianocosta89 merged 5 commits intoopen-telemetry:mainfrom
Conversation
Signed-off-by: svrnm <sneumann@causely.ai>
Signed-off-by: svrnm <sneumann@causely.ai>
|
@svrnm I'm having a hard time validating this. I've enabled the feature flag at 14:10. This is what I have in Grafana: During the spike from 13:45 to 13:50 the feature flag was disabled. |
|
@julianocosta89 thanks for checking, odd, that you can not see the spike. Here's how I tested it: I ran the flagd and email service in a docker container each I have not checked in those scripts, but I can make them available as needed. Let me go back myself and run it again. |
…ker compose Signed-off-by: svrnm <severin.neumann@altmuehlnet.de>
|
I forgot to add the For my own testing I created the following 2 files: When I use the "1000x" feature I can grow the memory quickly Interestingly I observed that the memory fills up until the memory limit (~100MB) and then garbage collection kicks in and cleans out some of the emails as well, so it would never crash, only fill memory up to max. |
|
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
julianocosta89
left a comment
There was a problem hiding this comment.
awesome!
Thank you @svrnm 🤩
Sorry for taking some time to come back to you.
I've tested it again today and it worked like a charm:
|
@svrnm would you be able to take care of adding this scenario here: https://opentelemetry.io/docs/demo/feature-flags/ ? |
of course :-) |

Changes
There is an existing memory leak in the email service, this PR turns this existing issue into a scenario that can be toggled by a feature flag. Since the leak is growing slowly by default (~1.4KB/email) I also added some way to speed things up by adding lots of whitespaces to the end of an email, up to 10000x, which leads to ~14MB/email, filling the memory rather quickly, especially in k8s where the default limit is ~100MB.
Note, that the default behavior is that the memory leak no longer shows up, by running
Mail::TestMailer.deliveries.clearafter each test email being put into memory with the "test" transport. I ran it that way for a while and the memory consumption stayed stable around ~50MB.Edited for more details
Merge Requirements
CHANGELOG.mdupdated to document new feature additions