06svenss

540
-1

Published on

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
540
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

06svenss

  1. 1. Programming Distributed Erlang Applications: Pitfalls and Recipes + A More Accurate Semantics for Distributed Erlang Hans Svensson Chalmers University of Technology Lars-Åke Fredlund Universidad Politécnica de Madrid Erlang Workshop, Freiburg, 5 Oct. 2007
  2. 2. Two Papers One Talk!? Message passing guarantees McErlang Pitfalls A More Accurate Semantics for Distributed Erlang A Semantics for Distributed Erlang Programming Distributed Erlang Applications: Pitfalls and Recipes Communication with dead processes Dropping messages
  3. 3. Talking to the Dead N 1 N 2 P 1 erlang:process_flag(trap_exit,true), Pid = spawn_link(N 2 ,m,addTwo,[]), -module(m). addTwo()-> receive {Pid,Num} -> Pid ! Num + 2 end, addTwo(). Pid ! {self(),5}, receive N -> io:format(“~p ”,[N]) end, 5+2 P 2 {P 1 ,5} 7
  4. 4. Talking to the Dead N 1 N 2 P 1 receive {‘EXIT’,Pid,Reason} –> ok end, P 2 {‘EXIT’,P 2 ,terminated}
  5. 5. Talking to the Dead N 1 N 2 P 1 -module(m2). mulTwo()-> receive {Pid,Num} -> Pid ! Num * 2 end, mulTwo(). Pid ! {self(),5}, receive N -> io:format(“~p ”,[N]) end, 5*2 ? ? {P 1 ,5} 10
  6. 6. Behind the scene <ul><li>N 2 was stopped and restarted </li></ul><ul><li>A new process managed to get exactly the same pid </li></ul><ul><li>Since the pid data structure is finite, this is expected, however… </li></ul><ul><li>The magic number is 3! </li></ul><ul><li>This ‘feature’ can not be modeled even in the more accurate semantics </li></ul>
  7. 7. Losing messages N 1 P 1 N 2 P 2 snd(Pid,N)-> Pid ! N, io:format(“~p “,[N]), timer:sleep(5000), snd(Pid,N+1). rcv()-> receive N -> io:format(“~p “,[N]), end, rcv(). 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 1 2 3 4 5 6 7 8 9 10 11 27 28 29 1 2 3 …
  8. 8. Behind the scene <ul><li>N 1 and N 2 was disconnected and later reconnected </li></ul><ul><li>Easily discovered by using links </li></ul><ul><li>Never rely on distributed communication without supervision </li></ul><ul><li>This scenario can be correctly modeled in the improved semantics </li></ul>
  9. 9. Distributed communication N 1 P 1 N 2 P 2 N 3 P 3 hello world world hello world world hello
  10. 10. Distributed communication N 1 P 1 N 2 P 2 N 3 P 3 hello world world P 3 hello world
  11. 11. Behind the scene <ul><li>Only one (TCP-)connection between N 1 and N 2 </li></ul><ul><li>A rather obscure guarantee </li></ul><ul><li>Not recommended to exploit this guarantee in application, future runtime systems might break it </li></ul><ul><li>This communication guarantee is not reflected in the semantics, there only the weaker guarantee holds </li></ul>
  12. 12. Practical considerations <ul><li>There is always a difference between any model and the actual runtime system </li></ul><ul><li>Artifacts of the OTP implementation of the runtime system should not be exploited </li></ul>
  13. 13. Changes in the Semantics <ul><li>New rules for node disconnect </li></ul><ul><li>Simplified rules for node failure and restart </li></ul><ul><li>A more compact formulation of fairness </li></ul><ul><li>Properties of the distributed semantics </li></ul><ul><ul><li>Extension </li></ul></ul><ul><ul><li>Message reordering and node disconnect </li></ul></ul><ul><ul><li>Expressiveness </li></ul></ul><ul><ul><li>Finite systems stays finite </li></ul></ul>
  14. 14. Survey!
  15. 15. Summary <ul><li>The possibility of reusing a Pid should not be neglected </li></ul><ul><li>Distributed communication should always be supervised </li></ul><ul><li>3 is quite a small number, is it possible to use a larger number? </li></ul>
  16. 16. A message from Lars-Åke <ul><li>He is at home, working on a new runtime system </li></ul><ul><li>He has not figured out the complete semantics, yet! </li></ul>Erik Hello world! (or will it be World Hello!)
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×