rpc/erpc behaviour

Bogdan Andu bog495@REDACTED
Fri Feb 25 09:55:50 CET 2022


While working with rpc and erpc call and cast I noticed
a strange behaviour and I don't know if this is intended or not.

Basically, a call to a Module.function on a local node, :'node1', creates a
process sub-tree that stays alive as expected.

However if the same cal to Module.function is performed from a remote node
with a rpc or erpc call from ;'node2':
(node2)> :rpc.cast(:'node1', Elixir.Module, :function, [args])
the process sub-tree created by Module.function on :'node1' dies .
I have tried every variant: :rpc.cast/call, :erpc.cast/call, even

Those calls are made from between nodes running as Elixir nodes.

Nodes are Erlang 24 and Elixir 1.12.2 (:'node2') and Elixir 1.13.0
The solution I founded is to use a Genserver which apparently keeps the
process sub-tree alive.

Is it normal that rpc calls cast ro call to end the function on the remote
node even if it has the side effects of starting process sub-tree?

Why is that happening? Is that normal?

>From the manual page:
"... It is used for collecting information on a remote node, or for running
a function with some *specific side effects *on the remote node."

Those side effects would mean in my case that the process sub-tree to
remain alive to use that as a service
but then again, that side effect disappears once the :rpc.cast/call ends.

I made a little test:
I put a :timer.sleep(10_000) at  the end of Module.function
and for 10 seconds the process sub-tree is alive, after that it is killed as
the function invoked remotely ends.

I want to invoke that function as a library call, not as a GenServer call.

How can I do that?

I want to wrap in GenServer locally the rpc calls to remote node function
as a library call.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20220225/c1a2ffd1/attachment.htm>

More information about the erlang-questions mailing list