engineeringdept

engineeringdept

Os_mon errors during shutdown on Heroku - advice on where to solve this?

OK, here’s a tricky issue, and I’m looking for a bit of advice about where to solve it…

We just enabled the New Relic agent in our Elixir app. It uses os_mon, from OTP, to poll for the cpu utilisation and report it back to New Relice. cpu_sup, the part of os_mon that deals with CPU reporting, uses a port subprocess, also called cpu_sup, to hook into the OS and retrieve the utilisation/load/etc.

Our application runs on Heroku. During the shutdown of a dyno, Heroku sends a SIGTERM to all processes, whether child or not. BEAM detects this and starts to shut down the applications in sequence. But the cpu_sup subprocess also receives this and immediately exits. The next time the New Relic agent polls, the cpu_sup GenServer process blows up with a ArgumentError as the port is no longer running.

So, where should we resolve this?

Is it a bug in Erlang/OTP that cpu_sup responds to a SIGTERM? I’m not sure what’s expected of ports here, but it feels like it’s important to be able to exit a detached subprocess with SIGTERM, if that ever occurs. I’m not convinced this process is doing anything wrong, per se.

Or is this an issue in Heroku that it sends SIGTERM to all processes, not just the parent/root process? If we controlled the OS and supervisor we wouldn’t send SIGTERM to all processes, but I can see why they do this. And I can’t see how we prevent it, at the moment.

Or can we trap this in the New Relic agent? I’m not sure how this would work, without trapping exits from the cpu_sup GenServer process, which feels a bit nasty.

Or should we just give in and ignore these errors in our exception tracking?

Any thoughts?

Where Next?

Popular in Questions Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New

We're in Beta

About us Mission Statement