[erlang-questions] Is -on_load() still experimental? Anyone using it?

Jachym Holecek <>
Fri Jan 24 18:58:22 CET 2014


Hi Ferenc,

# Ferenc Holzhauser 2014-01-24:
> Recently stumbled into the -on_load() directive. It seems nice to replace
> manual work (when possible) e.g. when a live update of a library module
> needs some environment/configuration change on the running system.
> 
> doc: http://www.erlang.org/doc/reference_manual/code_loading.html#id84676
> 
> It says it is experimental (since R13B03).
> After trying, it appears to be doing what I think it supposed to but
> looking at this note in the doc I'm not sure how safe it is to use in
> production.
> 
> Could somebody advise?

It is clearly not safe to use in production because that's what EXPERIMENTAL
means.

Also, the -on_load() functionality has been introduced to support automatic
NIF loading (not that this was a problem that really needed solving, IMHO).
Have you investigated if it really fits your use case well? This snippet
from documentation would unsettle me just a little bit on a live system:

  "A process that calls any function in a module whose on_load function
   has not yet returned will be suspended until the on_load function has
   returned."

It doesn't specify if this applies just to initial loading of a module or
also to runtime code updates, system behaviour in the latter case could
be disastrous.

Further, automatic configuration changes are a touchy topic. What if some-
thing goes wrong in the middle of your automatic update, and you end up
with inconsistent state? How do you rollback then? Especially if the
whole stuff is hidden where Operations won't see it?

Personally, I'd advise to solve boring problems in boring ways...

BR,
	-- Jachym



More information about the erlang-questions mailing list