airjulio

airjulio

Distillery hot-update for long running processes not working

I’ve been testing how hot updates behave for long running GenServers, but so far, the GenServer process is being killed whenever I upgrade. I have tried setting a higher :shutdown and adding Process.flag(:trap_exit, true) to the init callback function, but still without success.

Some relevant parts of my GenServer:

use GenServer, shutdown: 120 * 1000

  @doc false
  def start_link(_opts) do
    GenServer.start_link(__MODULE__, :ok, name: __MODULE__)
  end

  def run_testapp do
    GenServer.call(__MODULE__, {:run_testapp}, 60 * 1000)
  end

  @doc false
  @impl true
  def init(:ok) do
    Process.flag(:trap_exit, true)
    :ok
  end

  @doc false
  @impl true
  def handle_call({:run_testapp}, _from, state) do
    Process.sleep(24 * 1000)
    {:reply, %{a: 1}, state}
  end

Upgrades work fine if the process is not running, but otherwise the running process is killed and I get

** (exit) exited in: GenServer.call(Testapp.Server, {:run_testapp}, 60000)
    ** (EXIT) killed
    (elixir 1.10.0) lib/gen_server.ex:1023: GenServer.call/3
iex(app@127.0.0.1)5> Testapp.Server.run_testapp

Any ideas or resources that could help me?

Most Liked

gregvaughn

gregvaughn

At a low level module replacement only happens when you refer to the module explicitly. For example, calling MyModule.do_the_thing vs. calling do_the_thing from within MyModule. The first will cause a lookup in the code server for the latest version of MyModule. The latter will not.

Further, BEAM only allows 2 versions of one module to co-exist. If one module update happens, but some processes never call the fully qualified name before yet another version is deployed, then those processes are killed. That’s what sounds like is happening to you.

Where Next?

Popular in Questions Top

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
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
kostonstyle
Hi all I want to have a unix time, from the current time plus 1 hour. DateTime.now + 1 hour How to get it in elixir? Thanks
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New

Other popular topics Top

Tee
can someone please explain to me how Enum.reduce works with maps
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
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
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
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
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
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

We're in Beta

About us Mission Statement