[erlang-questions] runtime code upgrade, process ceases to exist.

Sid Muller <>
Thu Oct 1 18:08:06 CEST 2015


I'm struggling to understand this runtime code upgrade oddity and was hoping someone could shed some light on this issue.

The issue that I'm having is that the process running the latest code dies after the code is loaded with l(module) for the second time.

I understand that only 2 versions of the software can be running at any given time but what I'm not understanding is why does the process with the latest code die or go away.

I have process (a) that runs and calls b:do_stuff() which does stuff and responds back to (a).

Module b has an upgrade function that will call into the latest module:

   Ref = make_ref(),
   ?SERVER ! {self(), Ref, upgrade},
      {Ref, ok} ->

   Ref = make_ref(),
   ?SERVER ! {self(), Ref, do_stuff}, %% <-after second l(b) function fails here because ?SERVER is no longer registered, process is gone
      {Ref, ok} ->

      {Client, Ref, upgrade} ->
         Client ! {Ref, ok},
      {Client, Ref, do_stuff} ->
         Client ! {Ref, ok}

so after I load the new code with l(b). I call b:upgrade() from the shell and I can tell from the output in do_stuff() that new code is running when process a sends us do_stuff message. This is all fine until I make another change to module (b) but when I call l(b) process (b) is wiped out, gone, no more... It's not a crash in process (b), it just ceases to exist. And it's very frustrating because I have exactly the same code in another process which seems to survive multiple l(c) without any issues. The only difference between the two is that process(b) has a link to a dets process because it opens dets files and the link is created by the dets backend I believe.

I must not be understanding this hot code upgrade....

Can anyone shed any light on this?

More information about the erlang-questions mailing list