[erlang-questions] rpc call and mnesia transaction
Laszlo Lovei
lovei.laszlo@REDACTED
Sun Dec 16 11:48:14 CET 2012
Hi,
Dan is right, the issue is your code not being available on the remote
node, and the reason is the following. In this code:
(another@REDACTED)1> Fun = fun() -> mnesia:read(mytable, akey) end.
> #Fun<erl_eval.20.82930912>
>
the code referred by `Fun' is in the module `erl_eval' (as you can see from
#Fun<erl_eval....>). It is a symbolic evaluator which evaluates the code
you typed in the shell; the code itself is bound to variables in `Fun'
(stored in a kind of closure, which is sent over to the remote node during
the rpc call). This works because `erl_eval' is also loaded on the remote
node.
However, in this code:
-module(anrpctest).
>
> do() ->
> F = fun() -> mnesia:read(mytable, akey) end,
>
the code of `F' is compiled into the module `anrpctest', you can also see
this from the error message:
{aborted, {undef, [{#Fun<anrpctest.0.126678793>,[],[]},
>
This will work only if you load the module `anrpctest' on the remote node
too. (If you are just experimenting, use the l() command in a shell after
each recompilation.)
L.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121216/bec3436f/attachment.htm>
More information about the erlang-questions
mailing list