[erlang-questions] Lost messages

Robert Virding rvirding@REDACTED
Wed Jul 29 05:37:49 CEST 2009


The problem of catching messages which go to non-existent processes is
difficult and I don't believe there is a general solution which will handle
all cases. Off-hand I can think the following cases:

- The receiver process is on another node and the connection has gone down.
- The receiver has died before the message is sent.
- The receiver dies while the message is on it's way.
- The receiver dies after the message has arrived, but before it can be
received.
- The receiver dies after the message has been received but before it can
reply.
- The receiver is nasty and just doesn't bother to reply.
Etc...

I believe that you have to look at your app and let it decide how best to
detect and handle messages to which there is no reply. For example in the io
module the calls use monitor_process to detect if a process has died before
a reply message is sent, but this will not handle the case where the
receiver refuses to reply, while in the old telephony protocols there were
timeouts - if a reply didn't arrive within the timeout then it was an error
whatever the reason. Both these methods work well for some cases but can be
wrong for others.

This is one reason we never added a general RPC function. The simple
send/receive looks great but is not enough for serious applications, there
you need to roll your own case which does what you need. Joe Armstrong wrote
a good blog/posting (?) on that where he discussed the problem and showed
some of all the options for writing a "correct" RPC. I don't have the link
to it.

All this was not to say that the problem in unsolvable, just that you have
to work out what you need for your app. In your case maybe using
monitor_process might work.

Robert

2009/7/28 George Xu <xuxiang1@REDACTED>

> Yes,I already do the link and clean ETS table work. But no one can solve
> the race condition I think.
>
> So, in very rare case, I lost the message ('EXIT' is arrived after the
> message send out).
>
> I think this is not a "erLang way". It shall occur an error and let the
> sending process exit.
>
> Because that the message is important and the router which collect
> messages and send out can not be blocked by a dead / exit process, send a
> message back is not an acceptale solution.
>
> Does anyone have solutions for this?
>
> ━━━━━━━━━━━━━━━━━━━━━━━━━━
> 徐翔 George Xu
>
> Mobile Internet Service Lab, Lonovo Corp. Research China
> Tel:86-10-58866181
> E-mail:xuxiang1@REDACTED <E-mail%3Axuxiang1@REDACTED>
> No.6 Shang Di West Road, Haidian District,
> Beijing, 100085
> P.R.China
>


More information about the erlang-questions mailing list