erlang style error recovery for concurrent objects with
play

Erlang-style Error Recovery for Concurrent Objects with Cooperative - PowerPoint PPT Presentation

Erlang-style Error Recovery for Concurrent Objects with Cooperative Scheduling ori 1 Georg G Einar Broch Johnsen 2 Rudolf Schlatte 2 Volker Stolz 2 , 3 University of Technology, Graz, Austria goeri@student.tugraz.at University of Oslo, Norway


  1. Erlang-style Error Recovery for Concurrent Objects with Cooperative Scheduling ori 1 Georg G¨ Einar Broch Johnsen 2 Rudolf Schlatte 2 Volker Stolz 2 , 3 University of Technology, Graz, Austria goeri@student.tugraz.at University of Oslo, Norway { einarj,rudi,stolz } @ifi.uio.no Bergen University College, Norway http://www.envisage-project.eu 1 / 21

  2. Introduction Presented Work Rollback mechanism for communication through futures Erlang-style error handling primitives for ABS Motivation Erlang execution of ABS models Step towards distributed execution Errors inherent, consider modeling 2 / 21

  3. ABS - Abstract Behavioral Specification Developed as part of the HATS project, continued in ENVISAGE Concurrent object-oriented modeling language Active Objects Asynchronous Calls with Futures Concurrent Objects Groups (COG) / Processes Cooperative scheduling by explicit scheduling points Backends: Java, Maude, Erlang Proofs on class invariants over scheduling points, histories 3 / 21

  4. Erlang Erlang as Backend lightweight shared nothing process asynchronous message passing built-in distribution Error Handling used in high availability systems processes linking / monitors error propagation supervision 4 / 21

  5. Small Example MainBlock Output class Output i implements Output { { String last=””; Output o= new Output i(); Bool print(String s) { Fut < Bool > f=o ! print(”Hello World”); last=s; await f?; return True; Bool r = f. get ; } } } 5 / 21

  6. Bank account with transaction log Account Methods interface Account { Unit deposit (Int amount) { Unit deposit (Int amount); transactions = Unit withdraw (Int amount); Cons(amount, transactions); } balance = balance + amount; } class Account implements Account // log of transactions Unit withdraw (Int amount) { List < Int > transactions = Nil; transactions = // current balance Cons( − amount, transactions); Int balance = 0; if (balance < amount) abort ”Insu ffi cient funds”; balance = balance − amount; } 6 / 21

  7. Compare mechanisms in ABS and Erlang Erlang ABS Processes, Messages Active Objects, COGs, AsyncCalls, Futures Linking Exit Messages Error Propagation Error Handling 7 / 21

  8. Why model Errors? Distribution errors Connection / packet loss External world errors Through foreign function invocation e.g. I/O errors Resource errors Models closer to real implementations Guarding against invalid input or malfunctioning components 8 / 21

  9. Error Handling Error propagation through futures Rollback to preserve invariant New Syntax abort <Error> <Future>. safeget die <Error> 9 / 21

  10. Semantics abort <Error> AsyncCall terminates call, error stored in future, rollback ActiveObject object becomes invalid, terminate all AsyncCalls MainBlock runtime terminates <Future>. get An error e in the <Future> , will lead to an abort e <Future>. safeget Return value or error → enables error handling die <Error> Same as abort <Error> for active object. Object dies, further calls fail. 10 / 21

  11. Semantics abort <Error> AsyncCall terminates call, error stored in future, rollback ActiveObject object becomes invalid, terminate all AsyncCalls MainBlock runtime terminates <Future>. get An error e in the <Future> , will lead to an abort e <Future>. safeget Return value or error → enables error handling die <Error> Same as abort <Error> for active object. Object dies, further calls fail. 10 / 21

  12. Semantics abort <Error> AsyncCall terminates call, error stored in future, rollback ActiveObject object becomes invalid, terminate all AsyncCalls MainBlock runtime terminates <Future>. get An error e in the <Future> , will lead to an abort e <Future>. safeget Return value or error → enables error handling die <Error> Same as abort <Error> for active object. Object dies, further calls fail. 10 / 21

  13. Semantics abort <Error> AsyncCall terminates call, error stored in future, rollback ActiveObject object becomes invalid, terminate all AsyncCalls MainBlock runtime terminates <Future>. get An error e in the <Future> , will lead to an abort e <Future>. safeget Return value or error → enables error handling die <Error> Same as abort <Error> for active object. Object dies, further calls fail. 10 / 21

  14. Example Scenario RequestHandler reads/writes from KeyValueStore KeyValueStore value either in readCache or accessed via a Database File (opened per invocation) Error Handling KeyValueStore no special handling (= propagation, rollbacks) File die in case of read or write Error 11 / 21

  15. Example with rollback 12 / 21

  16. Example with rollback 12 / 21

  17. Example with rollback 12 / 21

  18. Example with rollback 12 / 21

  19. Example with rollback 12 / 21

  20. Example with rollback 12 / 21

  21. Example with rollback 12 / 21

  22. Example with rollback 12 / 21

  23. Example with rollback 12 / 21

  24. Example with rollback 12 / 21

  25. Example with rollback 12 / 21

  26. Example with rollback 12 / 21

  27. Example with rollback 12 / 21

  28. Example with rollback 12 / 21

  29. Example with rollback 12 / 21

  30. Example with rollback 12 / 21

  31. Example with rollback 12 / 21

  32. Example with rollback 12 / 21

  33. Example with rollback 12 / 21

  34. Example with rollback 12 / 21

  35. Example with rollback 12 / 21

  36. Example with rollback 12 / 21

  37. Example with rollback 12 / 21

  38. Example with rollback 12 / 21

  39. Example with rollback 12 / 21

  40. Example with rollback 12 / 21

  41. Example with rollback 12 / 21

  42. Towards Linking Link Linkable class Link(Linkable f,Linkable s) { Unit waitOn(Link l,Linkable la) { Int done=0; Fut < Unit > fut=la ! wait(); Unit setup() { l ! done(); f ! waiton( this ,s); await fut?; s ! waiton( this ,f); case fut. safeget { await done==2; Error(e) = > die e; } } } Unit done() { done=done+1; Unit wait() { } await false; } } 13 / 21

  43. Link Idea Nonterminating AsyncCall both ways Object1 Object2 wait wait 14 / 21

  44. Link Idea Nonterminating AsyncCall both ways Object1 Object2 Object1 Object2 wait error wait 14 / 21

  45. Implementing a Supervision tree Hierarchical process structure: parent ↔ child Restart strategies: one-for-one: one-for-all: (or propagate upwards) Images: OTP Design Principles User’s Guide 6.2, Ericsson AB 15 / 21

  46. Supervisor in ABS Starting a child Handle a deceased child Unit died(SupervisibleStarter ss, Unit start(SupervisibleStarter child) { String error) { SupervisorLink sl= new SupervisorLink( this ,child); case strategy { Link l= new Link(sl, this ); RestartAll = > this .restart(); await l ! setup(); RestartOne = > this .start(ss); this .links=Cons(sl,links); Prop = > die error; sl.start(); } } } 16 / 21

  47. Compare mechanisms in ABS and Erlang Erlang ABS Processes, Messages Active Objects, COGs, AsyncCalls, Futures Linking AsyncCalls: Built-in, Objects: Link Exit Messages Error stored in Future abort , die Error Propagation Through get Error Handling Through safeget No direct support Rollback 17 / 21

  48. But. . . how much does it cost? Rollbacks require to keep old object-state around Each asynchronous call duplicates callee state on demand ´ a la copy-on-write Release points ( suspend/await ) commit state No transactions (across release points) . . . but maybe easy to implement now? Distributed error detection more complicated. . . 18 / 21

  49. But. . . how much does it cost? Rollbacks require to keep old object-state around Each asynchronous call duplicates callee state on demand ´ a la copy-on-write Release points ( suspend/await ) commit state No transactions (across release points) . . . but maybe easy to implement now? Distributed error detection more complicated. . . 18 / 21

  50. But. . . how much does it cost? Rollbacks require to keep old object-state around Each asynchronous call duplicates callee state on demand ´ a la copy-on-write Release points ( suspend/await ) commit state No transactions (across release points) . . . but maybe easy to implement now? Distributed error detection more complicated. . . 18 / 21

  51. Conclusion Contributions Error Handling Error propagating futures Rollback language extensions in ABS Also: backend in Erlang magnitude faster smaller code distribution easier to implement Further work Tests in larger case study Extend model simulation in Maude Error handling analysis Fault injection 19 / 21

  52. Implementation & more Details: http://abs-models.org/ Thank you Also enjoy the following talk by Ivan: “Fault Model Design Space for Cooperative Concurrency” design space of faults once more, with exceptions 20 / 21

Recommend


More recommend