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

erlang style error recovery for concurrent objects with
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Erlang-style Error Recovery for Concurrent Objects with Cooperative Scheduling

Georg G¨

  • ri 1

Einar Broch Johnsen2 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

slide-2
SLIDE 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

slide-3
SLIDE 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

slide-4
SLIDE 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

slide-5
SLIDE 5

Small Example

MainBlock

{ Output o=new Output i(); Fut<Bool> f=o!print(”Hello World”); await f?; Bool r = f.get; }

Output

class Output i implements Output { String last=””; Bool print(String s){ last=s; return True; } }

5 / 21

slide-6
SLIDE 6

Bank account with transaction log

Account

interface Account { Unit deposit (Int amount); Unit withdraw (Int amount); } class Account implements Account // log of transactions List<Int> transactions = Nil; // current balance Int balance = 0;

Methods

Unit deposit (Int amount) { transactions = Cons(amount, transactions); balance = balance + amount; } Unit withdraw (Int amount) { transactions = Cons(−amount, transactions); if (balance < amount) abort ”Insufficient funds”; balance = balance − amount; }

6 / 21

slide-7
SLIDE 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

slide-8
SLIDE 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

slide-9
SLIDE 9

Error Handling

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

9 / 21

slide-10
SLIDE 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

slide-11
SLIDE 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

slide-12
SLIDE 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

slide-13
SLIDE 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

slide-14
SLIDE 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

slide-15
SLIDE 15

Example with rollback

12 / 21

slide-16
SLIDE 16

Example with rollback

12 / 21

slide-17
SLIDE 17

Example with rollback

12 / 21

slide-18
SLIDE 18

Example with rollback

12 / 21

slide-19
SLIDE 19

Example with rollback

12 / 21

slide-20
SLIDE 20

Example with rollback

12 / 21

slide-21
SLIDE 21

Example with rollback

12 / 21

slide-22
SLIDE 22

Example with rollback

12 / 21

slide-23
SLIDE 23

Example with rollback

12 / 21

slide-24
SLIDE 24

Example with rollback

12 / 21

slide-25
SLIDE 25

Example with rollback

12 / 21

slide-26
SLIDE 26

Example with rollback

12 / 21

slide-27
SLIDE 27

Example with rollback

12 / 21

slide-28
SLIDE 28

Example with rollback

12 / 21

slide-29
SLIDE 29

Example with rollback

12 / 21

slide-30
SLIDE 30

Example with rollback

12 / 21

slide-31
SLIDE 31

Example with rollback

12 / 21

slide-32
SLIDE 32

Example with rollback

12 / 21

slide-33
SLIDE 33

Example with rollback

12 / 21

slide-34
SLIDE 34

Example with rollback

12 / 21

slide-35
SLIDE 35

Example with rollback

12 / 21

slide-36
SLIDE 36

Example with rollback

12 / 21

slide-37
SLIDE 37

Example with rollback

12 / 21

slide-38
SLIDE 38

Example with rollback

12 / 21

slide-39
SLIDE 39

Example with rollback

12 / 21

slide-40
SLIDE 40

Example with rollback

12 / 21

slide-41
SLIDE 41

Example with rollback

12 / 21

slide-42
SLIDE 42

Towards Linking

Link

class Link(Linkable f,Linkable s){ Int done=0; Unit setup(){ f!waiton(this,s); s!waiton(this,f); await done==2; } Unit done(){ done=done+1; } }

Linkable

Unit waitOn(Link l,Linkable la){ Fut<Unit> fut=la!wait(); l!done(); await fut?; case fut.safeget { Error(e) => die e; } } Unit wait(){ await false; }

13 / 21

slide-43
SLIDE 43

Link Idea

Nonterminating AsyncCall both ways Object1 Object2 wait wait

14 / 21

slide-44
SLIDE 44

Link Idea

Nonterminating AsyncCall both ways Object1 Object2 wait wait Object1 Object2 error

14 / 21

slide-45
SLIDE 45

Implementing a Supervision tree

Hierarchical process structure: parent ↔ child Restart strategies:

  • ne-for-one:
  • ne-for-all:

(or propagate upwards)

Images: OTP Design Principles User’s Guide 6.2, Ericsson AB

15 / 21

slide-46
SLIDE 46

Supervisor in ABS

Starting a child

Unit start(SupervisibleStarter child){ SupervisorLink sl= new SupervisorLink(this,child); Link l=new Link(sl,this); await l!setup(); this.links=Cons(sl,links); sl.start(); }

Handle a deceased child

Unit died(SupervisibleStarter ss, String error){ case strategy { RestartAll => this.restart(); RestartOne => this.start(ss); Prop => die error; } }

16 / 21

slide-47
SLIDE 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

slide-48
SLIDE 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

slide-49
SLIDE 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

slide-50
SLIDE 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

slide-51
SLIDE 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

slide-52
SLIDE 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

  • nce more, with exceptions

20 / 21

slide-53
SLIDE 53

Further Reading

Johnsen, E. B., Lanese, I., and Zavattaro, G. Fault in the future. In Coordination Models and Languages, LNCS 6721, pages 1–15. Springer, 2011. Lanese, I., Lienhardt, M., Bravetti, M., Johnsen, E. B., Schlatte, R., Stolz, V., and Zavattaro, G. Fault Model Design Space for Cooperative Concurrency, In Proc. ISoLA’14, LNCS 8803, pages 23–37, Springer, 2014. Chang Din, C., Dovland, J., Johnsen, E. B., and Owe, O. Observable behavior of distributed systems: Component reasoning for concurrent objects.

  • J. of Log. and Alg. Prog., 81:227–256, 2012.

Johnsen, E. B., H¨ ahnle, R., Sch¨ afer, J., Schlatte, R., and Steffen, M. ABS: A core language for abstract behavioral specification. In FMCO, LNCS 6957, pages 142–164. Springer, 2012.

21 / 21