Slide 1

Slide 1 text

Invariant Safety for Distributed Applications 1 Sreeja Nair1, Gustavo Petri2, Marc Shapiro1 1 LIP6, Sorbonne University & Inria 2 ARM Research Cambridge The 6th Workshop on Principles and Practice of Consistency for Distributed Data PaPoC’19 25-03-2019

Slide 2

Slide 2 text

Distributed Applications • Modern day applications serve users in different geographical regions • Applications are replicated closer to users due to demands of low response time • CAP theorem depicts a tension between Consistency and Availability 2

Slide 3

Slide 3 text

Replicated Online Auction 3 Alice Bob Charles

Slide 4

Slide 4 text

Invariant Safety for Distributed Applications • Ideal world for developers = high availability + application safety • A modular proof rule to ensure this! • Reason about one operation at a time 4

Slide 5

Slide 5 text

Auction application • State • Status • INVALID or ACTIVE or CLOSED • Winner • Set of bids, each bid comprising • BidId • Placed • Amount 5 • Invariant • Bids can be placed only when the status is active • When auction is closed, there is a winner • Winner is the highest bid • Operations • Start auction • Place bid • Close auction

Slide 6

Slide 6 text

Evolution of state 6 Alice/ Australia Bob/ Belgium Charles/ Canada Start auction Place bid Place bid Status Winner Bids Merge! ??? 100 105 1 100 105 100 1 Close auction 100 1 100 105

Slide 7

Slide 7 text

Safety in sequential executions 7 Start auction Close auction Place Bid 100 Start auction Close auction Place Bid 100 100 105 100 105 100 105 100 105 100 105 105 100

Slide 8

Slide 8 text

Safety in sequential executions 8 Close auction 100 100 105 Close auction 100 100 95 100 95 100 105

Slide 9

Slide 9 text

Safety in sequential executions • Each operation and merge must satisfy the invariant • Ensured by preconditions 9

Slide 10

Slide 10 text

Precondition for merge? • It must hold true since merge can happen at any time • Can be also called Concurrent Invariant • The weakest precondition to be upheld for the resulting state of merge to uphold the sequential invariant • Ensures all concurrent operations are still safe • Never block any merge!! 10 Invglobal = Invapp ∧ Invconcurrent

Slide 11

Slide 11 text

Concurrency • A state in a replica evolves with • A local update by operation • Merge • Merge is the only point of observable concurrency 11 Alice/ Bob/ Charles Start Place Place 100 105 1 100 105 100 1

Slide 12

Slide 12 text

Proof Rule for safety of distributed applications • Initial state must satisfy the application invariant and concurrent invariant • Each update and merge should preserve both the application invariant and concurrent invariant 12

Slide 13

Slide 13 text

Proof Rule for safety of distributed applications • Intuition • Merge is the only point of external influence • Merge can happen any time • Modular • Each operation and merge reasoned in isolation 13

Slide 14

Slide 14 text

Revisiting auction • Invariant • Bids can be placed only when the status is active • When auction is closed, there is a winner • Winner is the highest bid • Concurrent Invariant • Winner in either state is the highest bid in both states 14

Slide 15

Slide 15 text

Safety of Auction 15 Alice/ Australia Bob/ Belgium Charles/ Canada Start auction Place bid Place bid 100 105 1 100 105 100 1 Close auction 100 1 100 105

Slide 16

Slide 16 text

Safety of Auction • Start auction 16 • Invariant • Bids can be placed only when the status is active • When auction is closed, there is a winner • Winner is the highest bid • Concurrent Invariant • Winner in either state is the highest bid in both states • Place bid • If auction concurrently closed in other replica, precondition of merge violated! • Close auction • Similar to place bid

Slide 17

Slide 17 text

Concurrency Control • Option 1: • Strong consistency of place bid and close auction operations • Issue: each place bid need synchronisation • Option 2: • Concurrency control similar to readers-writer lock • Place bids work without synchronisation • Closing auction needs synchronisation 17

Slide 18

Slide 18 text

18 Evolution of state with Concurrency Control Alice/ Australia Bob/ Belgium Charles/ Canada Start auction Place bid Place bid Close auction 100 Release token 100 105 Release token 105 Release token 1 1 100 105 105 100

Slide 19

Slide 19 text

Tool Support - Soteria • Implemented on top of Boogie • Input • Application state • Invariant • Partial Order function • Operations with preconditions • Merge operation with precondition 19

Slide 20

Slide 20 text

Soteria checks • Sanity checks • Convergence checks • Each operation is monotonically non-decreasing • Merge is the least upper bound • Safety checks • Sequential safety -> each operation preserves the invariant • Concurrent safety -> each operation preserves the precondition of merge 20

Slide 21

Slide 21 text

Semi-lattice • Set of state should form a monotonic semi-lattice • Equipped with a partial order function • Each update should inflate the state • Merge should be the Least Upper Bound 21 100 105 100 105

Slide 22

Slide 22 text

Conclusion • A new proof rule for verification of distributed applications • For applications using state-based update propagation • A tool for design verification • Available at https://github.com/sreeja/soteria_tool 22