[erlang-questions] Hot code loading and OTP
Jay Nelson
jay@REDACTED
Fri Sep 21 17:19:56 CEST 2007
A friend who hadn't seen erlang before just finished reading Joe's
book. We were discussing hot code loading and he didn't realize that
prefixing a function call with a Module: caused a load of code from
disk. I attempted to search through the book and find the
description, but was unable to find an explicit reference. Was this
accidentally left out?
My real question has to deal with OTP and relup / appup code
loading. Does the use of my error logging functions such as
my_logger:log_error(Msg) interfere with an orderly code upgrade?
Should I eschew all uses of Module:Function (I guess by using import,
unless there is some other mechanism to avoid triggering an unwanted
code load) so that code is only loaded on signal from an OTP upgrade?
I was just going to try an appup for the first time when it occurred
to me that the logger would get upgraded before the rest of the
system was even copied to disk properly depending on how I install
the software...
As I write this I think I've realized how OTP achieves the code
upgrade in an orderly fashion:
1) The OTP release system is guided by the current release version
and directory.
2) Any reference to M,F,A or M:F checks the initial location on disk
from which it was loaded -- which is determined by the release and
module-vsn.num directory name in the lib directory.
3) Appup and relup change the release number and vsn.num for all
modules on disk.
4) The triggering switch is controlled and causes a lockstep upgrade
by switching the code loader to be using the release directories.
Just be careful not to replace any beam file in place in a previous
release directory or you will get an uncontrolled code upgrade.
Is that all correct?
jay
More information about the erlang-questions
mailing list