What is `Creation` in Erlang Distribution Protocol

as in the topic, does anyone know what the Creation is? It appears in Distribution Protocol (can be returned by EPMD and has to be returned by listen function Erlang -- How to Implement an Alternative Carrier for the Erlang Distribution but I don’t fully get what it is used for :thinking:


The creation is used to tell nodes with the same name apart. When a PID (or port or ref) is sent from one node to the other the original node name and creation are embedded in the PID so that any process on any node can reply to it.

The creation is needed in order to distinguish between nodes where the connection was just lost, or the node crashed.

For example, if we have a@localhost and b@localhost. The process <0.123.0> on a@localhost sends this message to a process on b@localhost: PidOnB ! {echo,self()}. PidOnB then does some heavy calculations and is about to reply. Meanwhile, the connection between a@localhost and b@localhost is broken and then comes back.

Now when PidOnB wants to send its reply it does not know if the connection is just a@localhost that reconnected and the original process is still there, or if a@localhost restarted and now <0.123.0> is some other process. This is where the creation embedded in the PID that PidOnB received is used to check that the node that calls itself a@localhost is indeed the same node as sent the original message. So if it is the same node, the reply is sent as it normally would, while if the creation does not match, the reply message is just dropped.

Hope that makes sense. This is somewhat documented in the Erlang -- External Term Format documentation.


I havent explored it yet, so pardon my ignorance… but reading that sounds like it’s a unique identifier for the lifetime of a process… is it ok to assume so ?


It is more accurate to say that it is for the lifetime of the node.


Thanks a lot! One more question. Should I be able to use EPMD for node discovery when implementing alternative carrier for Distribution Protocol? When I am trying to run it I am getting na error suggesting that EPMD can only be used with TCP. Will send exact error ASAP


You need to connect to EPMD using TCP. If you cannot use TCP to connect to it then you need to use something different for node discovery. Or you can modify the epmd to use whatever protocol you would like.


By the way, I was always interested in making this creation field to not depend on EPMD (to a degree that I implemented my own epmd_module that returns creation based on time, which has a chance of collision).