[erlang-questions] Release upgrade

Ulf Wiger ulf.wiger@REDACTED
Wed Aug 26 12:08:04 CEST 2009


The basic principle behind code upgrade in Erlang
is that while you can simply load modules that are
not stateful, you usually need to take greater care
when state needs to be preserved or perhaps even transformed.

If you want running processes to automatically pick up
new code, you need to think through how to do this,
and there are different approaches depending on what the
code does.

A gen_server, for example, will always call the latest
version of the callback for each new request (since it
makes a qualified call to an exported function in the
callback module). For a controlled upgrade, you need
to 'suspend' the gen_server, trigger the Callbac:code_change/3
function, and then 'resume' the process.

The high-level instruction that gives this default
behaviour is

{update, Mod}

If the process doesn't "cooperate", you can insert an
instruction in the appup script that waits for e.g. uploads
to complete, somehow also making sure that new uploads
are not starting, then loads the module in question.

The low-level instruction {apply, {M, F, A}} can be used
to do this.

http://www.erlang.org/documentation/doc-5.6.3/lib/sasl-2.1.5.3/doc/html/appup.html

BR,
Ulf W


Felix wrote:
> Hi,
> I have some problem with code upgrade.
> Im tying to upgrade the code for uploading files with yaws while im
> uploading a file.
> My upgrade instruction in the .appup file is
> {load_module,my_upload_module}.
> 
> The upgrade goes well but it seems like upgrade is done on the
> currently running upload module when im doing
> release_handler:install_release/1 and thus kills the upload. I
> expected that the upgrade would take effect first at newly started
> uploads...
> Should I give a different upgrade instruction?
> 
> /
> 
> Felix
> 
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
> 


-- 
Ulf Wiger
CTO, Erlang Training & Consulting Ltd
http://www.erlang-consulting.com


More information about the erlang-questions mailing list