with

with

Prevent truncation of GenServer crashes

Hi,

I have a worker GenServer posting some results to its manager GenServer. The result is rather long and may contain hundreds of items. In some cases, this causes the manager GenServer to crash, however, I’m unable to see the stacktrace, because it gets truncated because of function argument size.

Here’s a shortened example:

02:17:00.222 [error] GenServer #PID<0.2821.0> terminating
** (stop) exited in: GenServer.call(Manager, {:post_results, %{data: ["2001167", "20011
68", "2001172", "2001169", "2001173", "2001176", "2001174", "2001175", "2001170", "20
01171", "2001178", "2001177", "2001196", "2001187", "2001188", "2001189", "2000489", "2001191", "2001192", "2001193", "2001194", "2001841", "202047
2", "2006815", "2019619", "2019942", "2020265", "2020588", "2019611", "201 (truncated)

This makes debugging the crashes very difficult. Is there a way to prevent the logs from truncating the crash data? Is there an alternative way of debugging such crashes?

Thank you!

Most Liked

NobbZ

NobbZ

You can set the :truncate option to an appropriate value:

:truncate - the maximum message size to be logged (in bytes). Defaults to 8192 bytes. Note this configuration is approximate. Truncated messages will have " (truncated)" at the end. The atom :infinity can be passed to disable this behavior.

50kudos

50kudos

I have exact same need (to see which file and line blows up), my solution is inspecting inside terminate/2 callback.

# You will know it when you need it
def terminate({_, trace}, _socket) do
  IO.inspect(trace, label: "terminate trace")
end

It will show file and line number without data log.

with

with

Unfortunately, the truncate setting has no effect, I’ve already tried that. Here’s my logger config:

config :logger,
  backends: [
    :console,
    {LoggerFileBackend, :error},
  ]
config :logger, :error,
  path: "/home/me/logs/scraper/error.log",
  level: :error,
  handle_otp_reports: true,
  handle_sasl_reports: true,
  truncate: :infinity

config :logger, :console,
  handle_otp_reports: true,
  handle_sasl_reports: true,
  level: :debug,
  truncate: :infinity

Both console, and the file have the log messages truncated.

Am I perhaps missing something?

Where Next?

Popular in Questions Top

nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a &gt; b) do {:ok, "a"} end if (a &lt; b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
JulienCorb
I am trying to implement my new.html.eex file to create new posts on my website. new.html.eex: &lt;h1&gt;Create Post&lt;/h1&gt; &lt;%= ...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

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
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39467 209
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
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
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
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

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement