[erlang-questions] Looking for info on hot code updates

Thomas Lindgren thomasl_erlang@REDACTED
Thu Nov 1 13:51:52 CET 2007

--- David Mitchell <monch1962@REDACTED> wrote:

> Hello all,
> Pure and simple - I'm looking for a pointer to info
> on doing hot code
> updates (i.e. update code while a server is running)
> in Erlang.  I've
> seen lots of talk about it, but nothing on:
> - how to do it
> - pros/cons/caveats/assumptions
> - what happens when that code is currently being
> executed by a running process
> If there's some magic combination of keywords
> that'll get me this info
> in Google, I can't work out what it is. 

Look for "erlang hot code loading". See also the
code(3) documentation and the OTP docs for
applications, releases, gen_* and so on. I think the
old Erlang book (available from erlang.org) has a bit
about this.

The low-level principles are these:

1. There can be up to two versions of a module loaded
at a given time, the 'old' version and the 'latest'
version. (The terminology is not quite standardized.)

2. Remote calls, m:f(...) always invoke the latest
version of a module. Thus, you often switch to "the
new code" by making a remote tail-call to yourself.
Local calls f(...) remain in the same module.

3. When a new version of a module is loaded, the
'latest' version becomes the 'old' version and the old
version is purged from the system/VM. When a module
version is purged, all processes referring to it are
killed (to avoid dead return addresses).

OTP and the gen_* framework then builds functionality
on top of this, e.g., "formal" upgrades and downgrades
and so on.


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

More information about the erlang-questions mailing list