[erlang-questions] Design to Avoid Races
Sat Sep 16 02:58:10 CEST 2006
I've been building a comet app with yaws, and I've run into a mental
block trying to get something "right".
Most of the examples in tutorials assume that an app is built out of a
number of processes communicating.
Suppose I have two users chatting, and my design calles for each user
to have a process. The processes were spawned when users created
sessions. The processes were linked when at some point the users chose
But suppose that one of the processes dies. If a supervisor restarts
it, it no longer knows about it's counterpart in the chat. If the
counterpart process was linked, presumably it has been killed and
restarted too. But now two users have lost contact.
Suppose the whole node is restarted. Now a bunch of users have lost
their state and have to find each other again.
Now suppose I keep the state of each process in an mnesia table. So
far so good. But if one process starts before it's counterpart and the
user starts chatting... or it dies before the counterpart is
started... now I have a bunch of race conditions and my head explodes.
Clearly I'm going down a mental rathole. With erlang this stuff is
supposed to be easier right? Can one of you veterans clear up a n00b?
More information about the erlang-questions