basic questions regarding message sequence guarantees...

Ulf Wiger ulf.wiger@REDACTED
Sat Apr 24 08:46:05 CEST 2004

On Fri, 23 Apr 2004 21:09:58 -0500, Kris Prieb 
<kris_prieb@REDACTED> wrote:

> 1.) Suppose I have a process 'A' and process 'B'.  'A' sends a sequence 
> of messages to 'B'.
> My understanding is that Erlang guarantees that B will receive the 
> messages from A in the order in which they were sent.
> Is this correct?


> 2.) Now suppose 'B' is monitoring 'A'.  Suppose also that another process
> 'C' is monitoring 'A' and that a 'Down' message from 'A' to 'C' will 
> trigger 'C' to send a message to 'B.'
> My understanding is that Erlang does _not_ guarantee that A's 'Down' 
> message to B will arrive before C's message to B.  Is this correct?


> 3.) Same as 2, except that B and C are on one node, and A is on another.
> Does this change anything?

It doesn't change the fact that Erlang gives no guarantee regarding the
relative order of messages if they travel different routes.

In this particular case, I think internal scheduling aspects would
determine the order in which messages arrive to B, so it's going to
be as uncertain as in (2).

Now, if 'A' and 'B' where on the same node, and 'C' were on a different
node, one could venture to guess that B would always receive A's
message first. However, there is still no guarantee, and I wouldn't
base my application logic on it. If you'd change the distribution
pattern for other reasons later, your code might break in mysterious

Ulf Wiger

More information about the erlang-questions mailing list