[erlang-questions] rpc call and mnesia transaction

Dan Gudmundsson dgud@REDACTED
Sat Dec 15 19:27:25 CET 2012


Your code is not available on the other node.
If that code is not in the code path.

But if want you can avoid the rpc if the node will be permanent,
it will be slightly slower though.

mnesia:start([{extra_db_nodes, [Node]}]),
mnesia:transaction(fun() -> mnesia:read(...) end).




On Sat, Dec 15, 2012 at 5:36 PM, <arif@REDACTED> wrote:

> Hi,
>
> I'm having some trouble with an rpc call in R5B03-1.
>
> I have one node, mnesianode@REDACTED, with mnesia running and with a table
> mytable.
>
> If I use rpc to read a record from a shell running on another node, it
> works fine.
>
> (another@REDACTED)1> Fun = fun() -> mnesia:read(mytable, akey) end.
> #Fun<erl_eval.20.82930912>
> (another@REDACTED)2> rpc:call('mnesianode@REDACTED', mnesia, transaction,
> [Fun]).
> {atomic,[{mytable,akey,<snip>}]}
> (another@REDACTED)3>
>
>
> However, if I put the code in a file:
>
> -module(anrpctest).
> -compile(export_all).
>
> do() ->
>     F = fun() -> mnesia:read(mytable, akey) end,
>     {atomic, Result} = rpc:call('mnesianode@REDACTED', mnesia, transaction,
> [F]),
>     Result.
>
> and try to execute anrpctest:do(), it fails.
>
> (another@REDACTED)4> c(anrpctest).
> {ok,anrpctest}
> (another@REDACTED)5> anrpctest:do().
> ** exception error: no match of right hand side value
>                     {aborted,
>                         {undef,
>                             [{#Fun<anrpctest.0.126678793>,[],[]},
>                              {mnesia_tm,apply_fun,3,
>                                  [{file,"mnesia_tm.erl"},{line,829}]},
>                              {mnesia_tm,execute_transaction,5,
>                                  [{file,"mnesia_tm.erl"},{line,809}]},
>                              {rpc,'-handle_call_call/6-fun-0-',5,
>                                  [{file,"rpc.erl"},{line,203}]}]}}
>      in function  anrpctest:do/0 (anrpctest.erl, ....
>
> Any idea why this is happening?
>
> Thanks and regards
> Arif
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121215/2f231be7/attachment.htm>


More information about the erlang-questions mailing list