Verification of Implementations of Distributed Systems under Churn - - PowerPoint PPT Presentation

verification of implementations of distributed systems
SMART_READER_LITE
LIVE PREVIEW

Verification of Implementations of Distributed Systems under Churn - - PowerPoint PPT Presentation

Verification of Implementations of Distributed Systems under Churn Ryan Doenges , James R. Wilcox, Doug Woos, Zachary Tatlock, and Karl Palmskog We should verify implementations of distributed systems... ...and we have! Framework Prover


slide-1
SLIDE 1

Verification of Implementations of Distributed Systems under Churn

Ryan Doenges, James R. Wilcox, Doug Woos, Zachary Tatlock, and Karl Palmskog

slide-2
SLIDE 2

We should verify implementations

  • f distributed systems...
slide-3
SLIDE 3

...and we have!

Framework Prover Verified system

Verdi Coq Raft consensus IronFleet Dafny Paxos consensus EventML NuPRL Paxos consensus Chapar Coq Key-value stores

slide-4
SLIDE 4

...and we have!

Framework Prover Verified system

Verdi Coq Raft consensus IronFleet Dafny Paxos consensus EventML NuPRL Paxos consensus Chapar Coq Key-value stores

slide-5
SLIDE 5

...and we have!

Framework Prover Verified system

Verdi Coq Raft consensus IronFleet Dafny Paxos consensus EventML NuPRL Paxos consensus Chapar Coq Key-value stores

Assumption: each node has a list of all nodes in the system

slide-6
SLIDE 6

Churn = nodes joining & leaving a system at run time

slide-7
SLIDE 7

Existing frameworks don't distinguish between knowing an address

“ ”

slide-8
SLIDE 8

and knowing a node's address.

slide-9
SLIDE 9

Under churn, systems depend

  • n a "routing table"

A B B

slide-10
SLIDE 10

But it can't be correct all of the time!

?

A B B C

slide-11
SLIDE 11

It can only be correct given enough time without churn: punctuated safety

A B B C C

slide-12
SLIDE 12

Our contributions

  • 1. First-class support for churn in

Verdi

  • 2. An approach to verifying punctuated safety
  • 3. Ongoing case studies
  • Tree-aggregation protocol
  • Chord distributed hash table
slide-13
SLIDE 13

Today

  • The tree-aggregation protocol
  • Churn in

Verdi

  • Proving punctuated safety
slide-14
SLIDE 14

An example: counting nodes

slide-15
SLIDE 15

These Pis live in Zach's office.

slide-16
SLIDE 16

We need them for experiments.

slide-17
SLIDE 17

They're subject to churn...

slide-18
SLIDE 18

but they can count themselves!

slide-19
SLIDE 19

Combine distributed data into a single global measurement Why not just ping every computer involved?

  • No fixed list of nodes under churn
  • The network may not be fully connected
  • Can't handle large networks efficiently

Tree-aggregation: the idea

slide-20
SLIDE 20
  • 1. Tree building: constructing a tree in the

network

  • 2. Data aggregation: moving data towards

the root of the tree Counting Pis is a very simple example. The protocol can aggregate more interesting data.

Tree-aggregation: 2 protocols

slide-21
SLIDE 21

A network of nodes

slide-22
SLIDE 22

Tree building: a root

slide-23
SLIDE 23

Tree building: broadcasting levels

"L = 0"

slide-24
SLIDE 24

Tree building: broadcasting levels

1

  • parent is least neighbor
  • level is parent's + 1
slide-25
SLIDE 25

Tree building: broadcasting levels

1 1 2 2

parent is least neighbor level is parent's + 1

2

slide-26
SLIDE 26

Aggregation: pending counts

1 +1 +1 +1 +1 +1

slide-27
SLIDE 27

Aggregation: send pending to parent

1 +1 +1 +1 +1 +1

slide-28
SLIDE 28

Aggregation: send pending to parent

1 +1 +1 +2 +1 +1

slide-29
SLIDE 29

6

The root gets the total count

slide-30
SLIDE 30

Handling churn: failures

2 +1 +1 +1 +1

slide-31
SLIDE 31

Handling churn: failures

2 +1 +1 +1 +1

slide-32
SLIDE 32

Handling churn: failures

2 +1 +1 +1 +1

−1

slide-33
SLIDE 33

Handling churn: failures

1 +1 +1 +1 +1

−1

slide-34
SLIDE 34

Handling churn: failures

1 +1 +1 +1 +1

slide-35
SLIDE 35

Handling churn: joins

1 +1 +1 +1 +1

slide-36
SLIDE 36

Handling churn: joins

1 +1 +1 +1 +1

slide-37
SLIDE 37

Handling churn: joins

1 2 3

slide-38
SLIDE 38

Handling churn: joins

1 2 2

slide-39
SLIDE 39

We can't finish counting during churn

6

slide-40
SLIDE 40

We can't finish counting during churn

6

!

slide-41
SLIDE 41

6

! " # $

We can't finish counting during churn

slide-42
SLIDE 42

Correctness (punctuated safety): Beginning from a state reachable under churn, given enough time without churn, the count at the root node becomes and remains correct

slide-43
SLIDE 43

Roadmap

  • The tree-aggregation protocol
  • Churn in

Verdi

  • Proving punctuated safety
slide-44
SLIDE 44

Roadmap

  • The tree-aggregation protocol
  • Churn in

Verdi

  • Proving punctuated safety
slide-45
SLIDE 45

Verdi workflow

  • 1. Write your system as event handlers
  • 2. Verify it using our network semantics
  • 3. Run it with the corresponding shim
slide-46
SLIDE 46

Handlers change local state and send messages.

Definition result :=
 state * list (addr * msg).

new state where to send it what to send

slide-47
SLIDE 47

Existing event: delivery

Definition result :=
 state * list (addr * msg). Definition recv_handler
 (dst : addr)
 (st : state)
 (src : addr)
 (m : msg)
 : result := ...

slide-48
SLIDE 48

New event: node start-up

Definition result :=
 state * list (addr * msg). Definition init_handler
 (h : addr)
 (knowns : list addr)
 : result := ...

slide-49
SLIDE 49

Record net :=
 {| failed_nodes : list addr;
 packets : addr -> addr -> list msg;
 state : addr -> state |}. Inductive step : net -> net -> Prop :=
 | Step_deliver : ...
 | Step_fail : ...

Semantics: fixed networks

% ☠

slide-50
SLIDE 50

Record net :=
 {| failed_nodes : list addr;
 packets : addr -> addr -> list msg;
 state : addr -> state |}. Inductive step : net -> net -> Prop :=
 | Step_deliver : ...
 | Step_fail : ...

Semantics: fixed networks

% ☠

probably Fin n

slide-51
SLIDE 51

Record net :=
 {| failed_nodes : list addr;
 nodes : list addr;
 packets : addr -> addr -> list msg;
 state : addr -> option state |}. Inductive step : net -> net -> Prop :=
 | Step_deliver : ...
 | Step_fail : ...
 | Step_init : ...

Semantics with churn

% ☠ '

slide-52
SLIDE 52

Now we can start verifying some properties of tree- aggregation!

slide-53
SLIDE 53
  • camlc

Shim (Ocaml) Handlers (Ocaml)

Extraction

Handlers (Coq)

The shim lets us run a system

slide-54
SLIDE 54
  • camlc

Shim (Ocaml) Handlers (Ocaml)

Extraction

Handlers (Coq)

We trust that the semantics describe the behavior of the shim and the network

slide-55
SLIDE 55

Roadmap

  • The tree-aggregation protocol
  • Churn in

Verdi

  • Proving punctuated safety
slide-56
SLIDE 56

Roadmap

  • The tree-aggregation protocol
  • Churn in

Verdi

  • Proving punctuated safety
slide-57
SLIDE 57

Churn forces safety violations

  • Routing information can't be right all

the time, and this typically violates top- level guarantees

  • In the case of tree aggregation, any

churn invalidates a correct total count

slide-58
SLIDE 58

Detour: safety and liveness properties

Safety: nothing bad ever happens Liveness: something good eventually happens

slide-59
SLIDE 59

Safety and liveness properties

Define execution = infinite sequence of system states, ordered by step relation. Then a safety property can be proved by examining only finite prefixes of an execution. A liveness property cannot be disproved by examining finite prefixes of an execution.

slide-60
SLIDE 60

We can prove safety properties with inductive invariants

A predicate P on states is an inductive invariant when

  • P holds for the initial state
  • P is preserved by the step
slide-61
SLIDE 61

Inductive invariants

A predicate P on states is an inductive invariant when

  • P holds for the initial state
  • P is preserved by the step
slide-62
SLIDE 62

Inductive invariants

...

A predicate P on states is an inductive invariant when

  • P holds for the initial state
  • P is preserved by the step
slide-63
SLIDE 63

Inductive invariants

...

If P implies our safety property, we've shown safety for all reachable states without needing to describe infinite executions in

  • ur Coq code!
slide-64
SLIDE 64

..but "the root node eventually has a correct count" isn't a safety property!

slide-65
SLIDE 65

Reachable

under churn

Safety

after churn stops

Punctuated safety properties

slide-66
SLIDE 66

Reachable

under churn

Safety

after churn stops

Punctuated safety properties

slide-67
SLIDE 67

...

Reachable

under churn ( )

Safety

after churn stops ( )

Punctuated safety properties

" e v e n t u a l l y "

slide-68
SLIDE 68

...

Punctuated safety properties

Reachable

under churn ( )

Safety

after churn stops ( )

slide-69
SLIDE 69

...

We don't know how to prove this yet

Reachable

under churn ( )

Safety

after churn stops ( )

slide-70
SLIDE 70

...

We don't know how to prove this yet

Reachable

under churn ( )

Safety

after churn stops ( )

It's a liveness argument, not a safety argument

slide-71
SLIDE 71

We need a way to talk about infinite executions: liveness can't be proved with only finite traces.

slide-72
SLIDE 72

Representing infinite executions in Coq

(* Infinite stream of terms in T *) CoInductive infseq (T : Type) := Cons : T -> infseq -> infseq. (* Stream of system states connected by step *) CoInductive execution : infseq (net * label) -> Prop := Cons_exec : forall n n', step n n' -> execution (Cons n' s) -> lb_execution (Cons n (Cons n' s)).

slide-73
SLIDE 73

... ... ...

Next P Always P Eventually P

Reasoning about executions: linear temporal logic (LTL)

...and much, much more!

slide-74
SLIDE 74

LTL in Coq

Inductive eventually P : infseq T -> Prop := | E0 : forall s, P s -> eventually P s | E_next : forall x s, eventually P s -> eventually P (Cons x s). CoInductive always P : infseq T -> Prop := | Always : forall s, P s ->
 always P (tl s) ->
 always P s.

slide-75
SLIDE 75

InfSeqExt: LTL in Coq

  • Extensions to a library by Deng &

Monin for doing LTL over infinite (coinductive) streams of events

  • Coq source code is on GitHub at

DistributedComponents/ InfSeqExt

slide-76
SLIDE 76

We still can't prove correctness

What if messages from one node are indefinitely delayed while messages from another are still delivered? Intuitively such an execution is "unfair" to the first node. We have to assume a fairness hypothesis.

slide-77
SLIDE 77

Weak fairness: If an action is eventually always enabled, then it is always eventually taken.

slide-78
SLIDE 78

Labels: turning steps into actions

... ... ...

SetParent h p SetCount h c S e n d C

  • u

n t h c

slide-79
SLIDE 79

SetCount h c is enabled at this state

... ... ...

SetParent h p SetCount h c S e n d C

  • u

n t h c

slide-80
SLIDE 80

SetCount h c is not taken in this execution, but SendCount h c is taken.

... ... ...

SetParent h p SetCount h c S e n d C

  • u

n t h c

slide-81
SLIDE 81

Note: fairness has to be implemented and assumed

The shim could fail to handle messages fairly and prevent liveness The network could delay packets and schedule delivery events unfairly

slide-82
SLIDE 82

We can now state correctness for tree aggregation!

∀ ex r,
 reachable_under_churn (hd ex) ->
 execution churn_free_step ex ->
 connected (hd ex) ->
 weakly_fair ex ->
 eventually (always
 (λ ex' =>
 correct_sum_at_root (hd ex')))
 ex

slide-83
SLIDE 83

Roadmap

  • The tree-aggregation protocol
  • Churn in

Verdi

  • Proving punctuated safety
slide-84
SLIDE 84

Roadmap

  • The tree-aggregation protocol
  • Churn in

Verdi

  • Proving punctuated safety
slide-85
SLIDE 85

Thanks!

We're on GitHub:

  • uwplse/verdi
  • DistributedComponents/verdi-aggregation
  • DistributedComponents/InfSeqExt
slide-86
SLIDE 86

Acknowledgements

Partially supported by the US National Science Foundation under grant CCF-1438982