74
1 Development of dynamically evolving and self-adaptive software 4. Dynamic software update LASER 2013 Isola d’Elba, September 2013 Carlo Ghezzi Politecnico di Milano Deep-SE Group @ DEIB Sunday, September 15, 13

Laser 4-dynamic update

Embed Size (px)

DESCRIPTION

Fourth lecture at the LASER Summer School, Elba Island, Sept. 2013

Citation preview

Page 1: Laser 4-dynamic update

1

Development of dynamically evolving and self-adaptive software

4. Dynamic software update

LASER 2013Isola d’Elba, September 2013

Carlo Ghezzi Politecnico di Milano

Deep-SE Group @ DEIB

Sunday, September 15, 13

Page 2: Laser 4-dynamic update

2

The problem

• Once you detect that a change has to be made to your running configuration, how do you react?

A solution• Replace distributed configuration A with B

Assumption• Componentized distributed implementation• Implementation structured as a program family• Reconfiguration = new family member instantiated

Sunday, September 15, 13

Page 3: Laser 4-dynamic update

3

The problem

• Traditional approach to software updates- Shut-down the system- Perform update- Restart

• Traditional program families instantiated statically• Here we need a dynamic program family

Sunday, September 15, 13

Page 4: Laser 4-dynamic update

Requirement

• The dynamic update has to be:• Efficient• Low disruption

minimize the interruption of the system’s service• Timely

minimize the delay with which the system is updated

• Safe• It must not lead the system into unexpected erroneous

behavior.

4Sunday, September 15, 13

Page 5: Laser 4-dynamic update

5

Our setting

• We assume we know the architecture of the system- System components and their interaction

• Based on the architecture, we define how can we safely replace a component at run-time by

- providing a condition to safely and efficiently substitute components at run-time

- an algorithm to ensure this condition- a framework that practically enables safe run-

time replacement of components when this condition is satisfied

Sunday, September 15, 13

Page 6: Laser 4-dynamic update

Software architecture model

• Component-based distributed systems may be described by the static configuration:• A directed graph whose:• nodes represent components with in-ports and out-ports• directed edges represents static dependences

6

DB�Portal�

Auth�

Proc�

com� :/Component�

:/Static,Dependence�

Static,configuration,/of/an/example/CBDS/7

Sunday, September 15, 13

Page 7: Laser 4-dynamic update

Transactions

• A transaction is a sequence of actions executed by a component that completes in bounded time• Actions include:• Local computations• Message exchanges

• A transaction can be:• a root transaction if initiated by an outside client

• a sub-transaction if initiated by another transaction

• A distributed transaction includes the root transaction and all (direct and indirect) sub-transactions

7Sunday, September 15, 13

Page 8: Laser 4-dynamic update

Transactions

AuthAuthPortalPortal ProcProc DBAccessDBAccess

T0T0

T1T1

T3T3

T2T2

T4T4

getToken (cred)

return token

process (token,data)

verify(token)

ok

dbOperation()

db result

proc result

root$transaction$$

sub,transaction$$

8Sunday, September 15, 13

Page 9: Laser 4-dynamic update

Requirement for a safe replacement a component at run-time

9

• We assume that the corresponding off-line update is correct

• The replacement is safe (correct) if• The transactions that end before the update satisfy

the old specification S• The transactions that begin after the update satisfy

the new specification S′ • The transactions that begin before the update, and

end after it, satisfy either S or S′

Sunday, September 15, 13

Page 10: Laser 4-dynamic update

How can we safely replace a component at run-time?

10

Different possible answers1. when it is idle (not currently holding a

transaction)2. when it is quiescent3. when it is tranquil4. in such a way that all transactions are kept

version consistent

Sunday, September 15, 13

Page 11: Laser 4-dynamic update

How can we safely replace a component at run-time?

10

Different possible answers1. when it is idle (not currently holding a

transaction)2. when it is quiescent3. when it is tranquil4. in such a way that all transactions are kept

version consistent

Sunday, September 15, 13

Page 12: Laser 4-dynamic update

Portal

T0

Auth Proc DB

T1

getToken(cred)

return  token

T2

process(token,  data)

T3

verify(token)

OK

T4

dbOp()

B✖

Idle:  It  is  not  currently  hosting  transactions.  

Replacing Auth when idle

Sunday, September 15, 13

Page 13: Laser 4-dynamic update

Portal

T0

Auth Proc DB

T1

getToken(cred)

return  token

T2

process(token,  data)

T3

verify(token)

OK

T4

dbOp()

A✔

D✔

C✔

Idle:  It  is  not  currently  hosting  transactions.  

Replacing Auth when idle

Sunday, September 15, 13

Page 14: Laser 4-dynamic update

Portal

T0

Auth Proc DB

T1

getToken(cred)

return  token

T2

process(token,  data)

T3

verify(token)

OK

T4

dbOp()

C✔Unsafe!

Replacing Auth when idle

Sunday, September 15, 13

Page 15: Laser 4-dynamic update

How can we safely replace a component at run-time?

12

Different possible answers1. when it is idle (not currently holding a

transaction)2. when it is quiescent3. when it is tranquil4. in such a way that all transactions are kept

version consistent

Sunday, September 15, 13

Page 16: Laser 4-dynamic update

How can we safely replace a component at run-time?

12

Different possible answers1. when it is idle (not currently holding a

transaction)2. when it is quiescent3. when it is tranquil4. in such a way that all transactions are kept

version consistent

Sunday, September 15, 13

Page 17: Laser 4-dynamic update

A node is quiescent if it is idle and the rest of the world has nothing to do with it

Precisely (Kramer and Magee):1. it is not currently engaged in a transaction that it initiated2. it will not initiate new transactions3. it is not currently engaged in servicing a transaction

4. no transactions have been or will be initiated by other nodes which require service from this node.

State of the art: Quiescence

13J. Kramer, J. Magee The evolving Philosophers Problem: Dynamic Change Management, TSE 1990.

Sunday, September 15, 13

Page 18: Laser 4-dynamic update

• To make a component quiescent, one need to passivate it and all components depending on it

14

DBPortal

Auth

Proc

Achieving quiescence

Sunday, September 15, 13

Page 19: Laser 4-dynamic update

• To make a component quiescent, one need to passivate it and all components depending on it

14

DBPortal

Auth

Proc

Achieving quiescence

Sunday, September 15, 13

Page 20: Laser 4-dynamic update

• To make a component quiescent, one need to passivate it and all components depending on it

14

DBPortal

Auth

Proc

Achieving quiescence

Sunday, September 15, 13

Page 21: Laser 4-dynamic update

• To make a component quiescent, one need to passivate it and all components depending on it

14

DBPortal

Auth

Proc

Achieving quiescence

Sunday, September 15, 13

Page 22: Laser 4-dynamic update

Portal

T0

Auth Proc DB

T1

getToken(cred)

return  token

T2

process(token,  data)

T3

verify(token)

OK

T4

dbOp()

A

C

D

15

Replacing Auth when quiescent

Sunday, September 15, 13

Page 23: Laser 4-dynamic update

How can we safely replace a component at run-time?

16

Different possible answers1. when it is idle (not currently holding a

transaction)2. when it is quiescent3. when it is tranquil4. in such a way that all transactions are kept

version consistent

Sunday, September 15, 13

Page 24: Laser 4-dynamic update

How can we safely replace a component at run-time?

16

Different possible answers1. when it is idle (not currently holding a

transaction)2. when it is quiescent3. when it is tranquil4. in such a way that all transactions are kept

version consistent

Sunday, September 15, 13

Page 25: Laser 4-dynamic update

A node is tranquil if it is idle and it is not between two interactions with the same neighbor

Precisely, (Vandewoude)1. it is not currently engaged in a transaction that it initiated,2. it will not initiate new transactions,3. it is not actively processing a request, and

4. none of its adjacent nodes are engaged in a transaction in which it has both already participated and might still participate in the future.

State of the art: Tranquility

17JI. Vandewoude et al. Tranquillity: A low-disruptive alternative to quiescence for ensuring safe dynamic updates, TSE 2007.

Sunday, September 15, 13

Page 26: Laser 4-dynamic update

Portal

T0

Auth Proc DB

T1

getToken(cred)

return  token

T2

process(token,  data)

T3

verify(token)

OK

T4

dbOp()

18

Replacing Auth when tranquil

Sunday, September 15, 13

Page 27: Laser 4-dynamic update

Portal

T0

Auth Proc DB

T1

getToken(cred)

return  token

T2

process(token,  data)

T3

verify(token)

OK

T4

dbOp()

18

A✔

Replacing Auth when tranquil

Sunday, September 15, 13

Page 28: Laser 4-dynamic update

Portal

T0

Auth Proc DB

T1

getToken(cred)

return  token

T2

process(token,  data)

T3

verify(token)

OK

T4

dbOp()

18

A✔

D✔

Replacing Auth when tranquil

Sunday, September 15, 13

Page 29: Laser 4-dynamic update

Portal

T0

Auth Proc DB

T1

getToken(cred)

return  token

T2

process(token,  data)

T3

verify(token)

OK

T4

dbOp()

18

A✔

C✔

D✔

Replacing Auth when tranquil

Sunday, September 15, 13

Page 30: Laser 4-dynamic update

How can we safely replace a component at run-time?

19

• Different possible answers1. when it is idle ß Not enough!2. when it is quiescent ß Safe, but can be disruptive3. when it is tranquil ß Less disruptive, but can be unsafe

Sunday, September 15, 13

Page 31: Laser 4-dynamic update

How can we safely replace a component at run-time?

19

• Different possible answers1. when it is idle ß Not enough!2. when it is quiescent ß Safe, but can be disruptive3. when it is tranquil ß Less disruptive, but can be unsafe4. in such a way that all transactions are kept version

consistent

Sunday, September 15, 13

Page 32: Laser 4-dynamic update

How can we safely replace a component at run-time?

19

• Different possible answers1. when it is idle ß Not enough!2. when it is quiescent ß Safe, but can be disruptive3. when it is tranquil ß Less disruptive, but can be unsafe4. in such a way that all transactions are kept version

consistent

Sunday, September 15, 13

Page 33: Laser 4-dynamic update

Version consistency

• A criterion for dynamic reconfiguration of CBDSs• as safe as the Quiescence

• more timely and less disruptive

• We introduce a Distributed Management Algorithm to achieve VC for the component (or the part of the system) to be updated.

20X. Ma, L. Baresi, C. Ghezzi, V. Panzica La Manna, J. Lu. Version-consistent Dynamic Reconfiguration of Component-based Distributed Systems. FSE 2011

Sunday, September 15, 13

Page 34: Laser 4-dynamic update

Intuitively: any extant transaction, with all its (direct and indirect) sub-

transactions, is executed as if it were entirely in the old or entirely in the new configuration

Version consistency

21

Transaction  T  is  version  consistent  with  respect  to  a  runtime  update  of  a  set  of  components  ω  with  a  new  version  ω′  iff                                                                                    .  

A  runtime  update  is  version  consistent  iff  all  transactions  are  version  consistent  with  respect  to  the  update

x)}(T,subTx|{xext(T) +∨==sub(T1,T2 ) T1 subtransaction of T2

Sunday, September 15, 13

Page 35: Laser 4-dynamic update

Portal

T0

Auth Proc DB

T1

getToken(cred)

return  token

T2

process(token,  data)

T3

verify(token)

OK

T4

dbOp()

A

C

D

22

Are the updates version consistent?

Sunday, September 15, 13

Page 36: Laser 4-dynamic update

Ensuring version consistency

23

•Distributed runtime model of dynamic dependences • Freeness as a locally checkable condition•Methods for achieving freeness

Sunday, September 15, 13

Page 37: Laser 4-dynamic update

24

DBPortal

Auth

Proc

Dynamic dependences

Sunday, September 15, 13

Page 38: Laser 4-dynamic update

24

DBPortal

Auth

Proc

futureT0

To  serve  transactions  in  ext(T0),Portal  might  initiate  transactions  on  Auth  in  the  future

Dynamic dependences

Sunday, September 15, 13

Page 39: Laser 4-dynamic update

24

DBPortal

Auth

Proc

futureT0

To  serve  transactions  in  ext(T0),Portal  might  initiate  transactions  on  Auth  in  the  future

pastT0

Auth  has  hosted  transactions  in  ext(T0)  initiated  by  Portal  in  the  past

Dynamic dependences

Sunday, September 15, 13

Page 40: Laser 4-dynamic update

24

DBPortal

Auth

Proc

futureT0

To  serve  transactions  in  ext(T0),Portal  might  initiate  transactions  on  Auth  in  the  future

pastT0

Auth  has  hosted  transactions  in  ext(T0)  initiated  by  Portal  in  the  past

Auth  is  currently  hosting  transactions  in  ext(T0)

futureT0

pastT0

Dynamic dependences

Sunday, September 15, 13

Page 41: Laser 4-dynamic update

24

DBPortal

Auth

Proc

futureT0

To  serve  transactions  in  ext(T0),Portal  might  initiate  transactions  on  Auth  in  the  future

pastT0

Auth  has  hosted  transactions  in  ext(T0)  initiated  by  Portal  in  the  past

Auth  is  currently  hosting  transactions  in  ext(T0)

futureT0

pastT0

It’s  a  distributed  runtime  model

Dynamic dependences

Sunday, September 15, 13

Page 42: Laser 4-dynamic update

Valid configuration

25

• A configuration with dynamic dependencies is a distributed runtime model- Dynamic dependences are represented by future and

past edges created and removed at runtime- Each node is in charge of edges leaving from it and

aware of edges entering it

• A valid configuration must satisfy certain invariants on edges

Sunday, September 15, 13

Page 43: Laser 4-dynamic update

A component is said to be free in G if it is free of dependence by all root transactions whose identifiers appears in G.

Freeness is sufficient for version consistency

Freeness

Given a configuration with dynamic dependence G, a component C is said to be free of dependence with respect to a root transaction T if there does not exist a pair of future/past edges labeled with T arriving at C

A component is said to be free in G if it is free of dependence by all root transactions whose identifiers appear in G

26

Freeness is a locally checkable condition

A dynamic update of a component is version consistent if it happens when the component is idle and free

Sunday, September 15, 13

Page 44: Laser 4-dynamic update

The configuration with dynamic dependences is maintained at runtime, in a distributed way

When a root transaction is started, a setup of all future edges is performed

In practice, future edge information is stored locallyEach node stores info about its incoming past and future edges

Future edges are then eliminated and past edges created as the transaction is in progress

A cleanup phase that eliminates remaining future/past edges is performed upon termination of the transaction.

Managing dynamic dependences

27Sunday, September 15, 13

Page 45: Laser 4-dynamic update

1) Setup (at the beginning of a rootTx): Recursively create enough future edges

28Sunday, September 15, 13

Page 46: Laser 4-dynamic update

29

1) Setup (at the beginning of a rootTx): Recursively create enough future edges

Sunday, September 15, 13

Page 47: Laser 4-dynamic update

30

1) Setup (at the beginning of a rootTx): Recursively create enough future edges

Sunday, September 15, 13

Page 48: Laser 4-dynamic update

31

1) Setup (at the beginning of a rootTx): Recursively create enough future edges

Sunday, September 15, 13

Page 49: Laser 4-dynamic update

32

1) Setup (at the beginning of a rootTx): Recursively create enough future edges

Sunday, September 15, 13

Page 50: Laser 4-dynamic update

2) Progressing (on the beginning/ending subTxs): Progressively Remove Future Edges And Create Past Edges

33Sunday, September 15, 13

Page 51: Laser 4-dynamic update

34

2) Progressing (on the beginning/ending subTxs): Progressively Remove Future Edges And Create Past Edges

Sunday, September 15, 13

Page 52: Laser 4-dynamic update

35

2) Progressing (on the beginning/ending subTxs): Progressively Remove Future Edges And Create Past Edges

Sunday, September 15, 13

Page 53: Laser 4-dynamic update

36

2) Progressing (on the beginning/ending subTxs): Progressively Remove Future Edges And Create Past Edges

Sunday, September 15, 13

Page 54: Laser 4-dynamic update

37

2) Progressing (on the beginning/ending subTxs): Progressively Remove Future Edges And Create Past Edges

Sunday, September 15, 13

Page 55: Laser 4-dynamic update

38

2) Progressing (on the beginning/ending subTxs): Progressively Remove Future Edges And Create Past Edges

Sunday, September 15, 13

Page 56: Laser 4-dynamic update

39

2) Progressing (on the beginning/ending subTxs): Progressively Remove Future Edges And Create Past Edges

Sunday, September 15, 13

Page 57: Laser 4-dynamic update

40

2) Progressing (on the beginning/ending subTxs): Progressively Remove Future Edges And Create Past Edges

Sunday, September 15, 13

Page 58: Laser 4-dynamic update

41

2) Progressing (on the beginning/ending subTxs): Progressively Remove Future Edges And Create Past Edges

Sunday, September 15, 13

Page 59: Laser 4-dynamic update

42

2) Progressing (on the beginning/ending subTxs): Progressively Remove Future Edges And Create Past Edges

Sunday, September 15, 13

Page 60: Laser 4-dynamic update

43

2) Progressing (on the beginning/ending subTxs): Progressively Remove Future Edges And Create Past Edges

Sunday, September 15, 13

Page 61: Laser 4-dynamic update

44

2) Progressing (on the beginning/ending subTxs): Progressively Remove Future Edges And Create Past Edges

Sunday, September 15, 13

Page 62: Laser 4-dynamic update

45

2) Progressing (on the beginning/ending subTxs): Progressively Remove Future Edges And Create Past Edges

Sunday, September 15, 13

Page 63: Laser 4-dynamic update

46

2) Progressing (on the beginning/ending subTxs): Progressively Remove Future Edges And Create Past Edges

Sunday, September 15, 13

Page 64: Laser 4-dynamic update

47

2) Progressing (on the beginning/ending subTxs): Progressively Remove Future Edges And Create Past Edges

Sunday, September 15, 13

Page 65: Laser 4-dynamic update

48

2) Progressing (on the beginning/ending subTxs): Progressively Remove Future Edges And Create Past Edges

Sunday, September 15, 13

Page 66: Laser 4-dynamic update

3) Clean-up (on the ending of RootTx ): Recursively remove past edges and remaining future edges

49Sunday, September 15, 13

Page 67: Laser 4-dynamic update

50

3) Clean-up (on the ending of RootTx ): Recursively remove past edges and remaining future edges

Sunday, September 15, 13

Page 68: Laser 4-dynamic update

Achieving freeness

1. Waiting for freeness to manifest itself (WF)• Low disruption, but no guarantee for timeliness. Freeness can be never

achieved.

2. Using concurrent versions of the components (CV)• Our framework makes it easy to decide • Which version for which request, and• When the old version can retire.

• Preferred If feasible. Timely and low disruptive.

3. Blocking transactions to achieve freeness (BF)• Timely, but more disruptive than WF/CV.

51Sunday, September 15, 13

Page 69: Laser 4-dynamic update

Evaluation

• Goal: To evaluate timeliness and disruption

• Compare our approach with the quiescence approach

• Study the impact of network latency

• Method: Discrete event simulations

• Timeliness: time span between request and ready state

• Disruption: loss of working time wrt. no reconfiguration

52Sunday, September 15, 13

Page 70: Laser 4-dynamic update

Experiment 1: Timeliness

Our approach can be (~20%) more timely

53Sunday, September 15, 13

Page 71: Laser 4-dynamic update

Experiment 1: Disruption

Our approach can be significantly less disruptive (~50% for BF and negligible for CV)

54Sunday, September 15, 13

Page 72: Laser 4-dynamic update

Experiment 2: Network Latency

Our approach is consistently better in disruption but its gain in timeliness diminishes while message delay increases.

55Sunday, September 15, 13

Page 73: Laser 4-dynamic update

56

[ESEC/FSE 2011] X, Ma, L, Baresi, C, Ghezzi, V. Panzica La Manna, and J. Lu, “Version-consistent Dynamic Reconfiguration of Component-based Distributed Systems”

[SEAMS 2012] C. Ghezzi, J. Greenyer, V. Panzica La Manna, "Synthesizing Dynamically Updating Controllers from Changes in Scenario-based Specifications"

[SEAMS 2013] V. Panzica La Manna, , J. Greenyer, C. Ghezzi, C. Brenner, “Formalizing Correctness Criteria of Dynamic Updates Derived from Specification Changes”

From components to a specification-based approach

Sunday, September 15, 13

Page 74: Laser 4-dynamic update

57

Acknowledgements• Most of the ideas discussed here matured or developed thanks to

a funding from the European Research Council (Advanced Grant IDEAS-ERC, Project 227977---SMScom)

• ...and thanks to

Sunday, September 15, 13