relational reasoning for mergeable replicated data types
play

Relational Reasoning for Mergeable Replicated Data Types KC - PowerPoint PPT Presentation

Relational Reasoning for Mergeable Replicated Data Types KC Sivaramakrishnan joint work with Gowtham Kaki, Swarn Priya, Suresh Jagannathan 1 INTERNET INTERNET INTERNET INTERNET Serializability Linearizability Weak


  1. module Counter : sig type t val read : t -> int 7 val add : t -> int -> t +1 *3 val sub : t -> int -> t val mult : t -> int -> t val merge : lca:t -> v1:t -> v2:t -> t 8 21 end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d let mult x n = x * n let merge ~lca ~v1 ~v2 = lca + (v1 - lca) + (v2 - lca) end � 12

  2. module Counter : sig type t val read : t -> int 7 val add : t -> int -> t +1 *3 val sub : t -> int -> t val mult : t -> int -> t val merge : lca:t -> v1:t -> v2:t -> t 8 21 end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d 22 let mult x n = x * n let merge ~lca ~v1 ~v2 = lca + (v1 - lca) + (v2 - lca) end � 12

  3. module Counter : sig type t val read : t -> int 7 val add : t -> int -> t +1 *3 val sub : t -> int -> t val mult : t -> int -> t val merge : lca:t -> v1:t -> v2:t -> t 8 21 end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d 22 22 let mult x n = x * n let merge ~lca ~v1 ~v2 = lca + (v1 - lca) + (v2 - lca) end � 12

  4. module Counter : sig type t val read : t -> int 7 val add : t -> int -> t +1 *3 val sub : t -> int -> t val mult : t -> int -> t val merge : lca:t -> v1:t -> v2:t -> t 8 21 end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d 22 22 let mult x n = x * n let merge ~lca ~v1 ~v2 = 22 = 7 + (8-1) + (21 -7) lca + (v1 - lca) + (v2 - lca) end � 12

  5. module Counter : sig type t val read : t -> int 7 val add : t -> int -> t +1 *3 val sub : t -> int -> t val mult : t -> int -> t val merge : lca:t -> v1:t -> v2:t -> t 8 21 end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d 22 22 let mult x n = x * n let merge ~lca ~v1 ~v2 = 22 = 7 + (8-1) + (21 -7) lca + (v1 - lca) + (v2 - lca) end • 3-way merge function makes the counter suitable for distribution � 12

  6. module Counter : sig type t val read : t -> int 7 val add : t -> int -> t +1 *3 val sub : t -> int -> t val mult : t -> int -> t val merge : lca:t -> v1:t -> v2:t -> t 8 21 end = struct type t = int let read x = x let add x d = x + d let sub x d = x - d 22 22 let mult x n = x * n let merge ~lca ~v1 ~v2 = 22 = 7 + (8-1) + (21 -7) lca + (v1 - lca) + (v2 - lca) end • 3-way merge function makes the counter suitable for distribution • Does not appeal to individual operations => independently extend data-type � 12

  7. Systems ➞ PL � 13

  8. Systems ➞ PL • CRDTs need to take care of systems level concerns such as exactly once delivery � 13

  9. Systems ➞ PL • CRDTs need to take care of systems level concerns such as exactly once delivery • 3-way merge handles it automatically � 13

  10. Systems ➞ PL 7 • CRDTs need to take care of +1 *3 systems level concerns such as exactly once delivery 8 21 • 3-way merge handles it automatically 22 22 � 13

  11. Systems ➞ PL 7 • CRDTs need to take care of +1 *3 systems level concerns such as exactly once delivery 8 21 • 3-way merge handles it automatically 22 22 ?? � 13

  12. Systems ➞ PL 7 • CRDTs need to take care of +1 *3 systems level concerns such as exactly once delivery 8 21 • 3-way merge handles it automatically 22 22 22 ?? 22 = 21 + (21-21) + (22 -21) � 13

  13. Does the 3-way merge idea generalise?

  14. module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end � 15

  15. module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end • Try replicating queues by asynchronously transmitting operations � 15

  16. module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end • Try replicating queues by asynchronously transmitting operations [1,2] � 15

  17. module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end • Try replicating queues by asynchronously transmitting operations [1,2] pop() � 1 [2] � 15

  18. module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end • Try replicating queues by asynchronously transmitting operations [1,2] pop() � 1 pop() � 1 [2] [2] � 15

  19. module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end • Try replicating queues by asynchronously transmitting operations [1,2] pop() � 1 pop() � 1 [2] [2] pop() [ ] � 15

  20. module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end • Try replicating queues by asynchronously transmitting operations [1,2] pop() � 1 pop() � 1 [2] [2] pop() pop() [ ] [ ] � 15

  21. module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end • Try replicating queues by asynchronously transmitting operations [1,2] pop() � 1 pop() � 1 [2] [2] pop() pop() [ ] [ ] • Convergence is not sufficient; Intent is not preserved � 15

  22. module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end • Try replicating queues by asynchronously transmitting operations [1,2] [1] pop() � 1 pop() � 1 [2] [2] pop() pop() [ ] [ ] • Convergence is not sufficient; Intent is not preserved � 15

  23. module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end • Try replicating queues by asynchronously transmitting operations [1,2] [1] pop() � 1 pop() � 1 push(2) [2] [2] [1,2] pop() pop() [ ] [ ] • Convergence is not sufficient; Intent is not preserved � 15

  24. module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end • Try replicating queues by asynchronously transmitting operations [1,2] [1] pop() � 1 pop() � 1 push(2) push(3) [2] [2] [1,2] [1,3] pop() pop() [ ] [ ] • Convergence is not sufficient; Intent is not preserved � 15

  25. module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end • Try replicating queues by asynchronously transmitting operations [1,2] [1] pop() � 1 pop() � 1 push(2) push(3) [2] [2] [1,2] [1,3] pop() push(3) pop() [ ] [ ] [1,2,3] • Convergence is not sufficient; Intent is not preserved � 15

  26. module type Queue = sig type 'a t val push : 'a t -> 'a -> 'a t val pop : 'a t -> ('a * 'a t) option (* at-least once semantics *) end • Try replicating queues by asynchronously transmitting operations [1,2] [1] pop() � 1 pop() � 1 push(2) push(3) [2] [2] [1,2] [1,3] pop() push(2) push(3) pop() [ ] [ ] [1,2,3] [1,3,2] • Convergence is not sufficient; Intent is not preserved � 15

  27. Concretising Intent � 16

  28. Concretising Intent • Intent is a woolly term ★ How can we formalise the intent of operations on a data structure? � 16

  29. Concretising Intent • Intent is a woolly term ★ How can we formalise the intent of operations on a data l structure? v1 v2 v � 16

  30. Concretising Intent • Intent is a woolly term ★ How can we formalise the intent of operations on a data l structure? • For a replicated queue, v1 v2 v � 16

  31. Concretising Intent • Intent is a woolly term ★ How can we formalise the intent of operations on a data l structure? • For a replicated queue, v1 v2 1. Any element popped in either v1 or v2 does not remain in v v � 16

  32. Concretising Intent • Intent is a woolly term ★ How can we formalise the intent of operations on a data l structure? • For a replicated queue, v1 v2 1. Any element popped in either v1 or v2 does not remain in v v 2. Any element pushed into either v1 or v2 appears in v � 16

  33. Concretising Intent • Intent is a woolly term ★ How can we formalise the intent of operations on a data l structure? • For a replicated queue, v1 v2 1. Any element popped in either v1 or v2 does not remain in v v 2. Any element pushed into either v1 or v2 appears in v 3. An element that remains untouched in l, v1, v2 remains in v � 16

  34. Concretising Intent • Intent is a woolly term ★ How can we formalise the intent of operations on a data l structure? • For a replicated queue, v1 v2 1. Any element popped in either v1 or v2 does not remain in v v 2. Any element pushed into either v1 or v2 appears in v 3. An element that remains untouched in l, v1, v2 remains in v 4. Order of pairs of elements in l, v1, v2 must be preserved in m, if those elements are present in v. � 16

  35. Relational Specification � 17

  36. Relational Specification • Let’s define relations R mem and R ob to capture membership and ordering ★ R mem [1,2,3] = {1,2,3} ★ R ob [1,2,3] = { (1,2), (1,3), (2,3) } � 17

  37. Relational Specification • Let’s define relations R mem and R ob to capture membership and ordering l ★ R mem [1,2,3] = {1,2,3} v1 v2 ★ R ob [1,2,3] = { (1,2), (1,3), (2,3) } v � 17

  38. Relational Specification • Let’s define relations R mem and R ob to capture membership and ordering l ★ R mem [1,2,3] = {1,2,3} v1 v2 ★ R ob [1,2,3] = { (1,2), (1,3), (2,3) } v � 17

  39. Relational Specification • Let’s define relations R mem and R ob to capture membership and ordering l ★ R mem [1,2,3] = {1,2,3} v1 v2 ★ R ob [1,2,3] = { (1,2), (1,3), (2,3) } v 1.Any element popped in either v1 or v2 does not remain in v � 17

  40. Relational Specification • Let’s define relations R mem and R ob to capture membership and ordering l ★ R mem [1,2,3] = {1,2,3} v1 v2 ★ R ob [1,2,3] = { (1,2), (1,3), (2,3) } v 1.Any element popped in either v1 or v2 does not remain in v 2. Any element pushed into either v1 or v2 appears in v � 17

  41. Relational Specification • Let’s define relations R mem and R ob to capture membership and ordering l ★ R mem [1,2,3] = {1,2,3} v1 v2 ★ R ob [1,2,3] = { (1,2), (1,3), (2,3) } v 1.Any element popped in either v1 or v2 does not remain in v 2. Any element pushed into either v1 or v2 appears in v 3. An element that remains untouched in l, v1, v2 remains in v � 17

  42. Relational Specification l v1 v2 v � 18

  43. Relational Specification l v1 v2 v • RHS has to be confined to R mem (v) x R mem (v) since certain orders might be missing ★ Consider l = [0], v1= [0,1], v2 = [ ], v = [1] � 18

  44. Relational Specification l v1 v2 v • RHS has to be confined to R mem (v) x R mem (v) since certain orders might be missing ★ Consider l = [0], v1= [0,1], v2 = [ ], v = [1] • RHS is an underspecification since orders between concurrent insertions will only be present in R ob (v) ★ Consider l = [ ], v1= [0], v2 = [1], v = [0,1] � 18

  45. � 19

  46. R mem = {1,2} R ob = { (1,2) } [1,2] � 19

  47. R mem = {1,2} R ob = { (1,2) } [1,2] pop() � 1 R mem = {2} [2] R ob = { } � 19

  48. R mem = {1,2} R ob = { (1,2) } [1,2] pop() � 1 pop() � 1 R mem = {2} R mem = {2} [2] [2] R ob = { } R ob = { } � 19

  49. R mem = {1,2} R ob = { (1,2) } [1,2] pop() � 1 pop() � 1 R mem = {2} R mem = {2} [2] [2] R ob = { } R ob = { } R mem = {2} R mem = {2} [2] [2] R ob = { } R ob = { } � 19

  50. � 20

  51. R mem = {1} R ob = { } [1] � 20

  52. R mem = {1} R ob = { } [1] push(2) R mem = {1,2} [1,2] R ob = { (1,2) } � 20

  53. R mem = {1} R ob = { } [1] push(2) push(3) R mem = {1,2} R mem = {1,3} [1,2] [1,3] R ob = { (1,2) } R ob = { (1,3) } � 20

  54. R mem = {1} R ob = { } [1] push(2) push(3) R mem = {1,2} R mem = {1,3} [1,2] [1,3] R ob = { (1,2) } R ob = { (1,3) } Use < as an arbitration function between concurrent insertions � 20

  55. R mem = {1} R ob = { } [1] push(2) push(3) R mem = {1,2} R mem = {1,3} [1,2] [1,3] R ob = { (1,2) } R ob = { (1,3) } [1,2,3] [1,3,2] R mem = {1,2,3} R mem = {1,2,3} R ob = { (1,2), (1,3), (2,3) } R ob = { (1,2), (1,3). (2,3) } Use < as an arbitration function between concurrent insertions � 20

  56. Characteristic Relations A sequence of relations R T is called a characteristic relation of a data type T, if for every x : T and y : T , R T ( x ) = R T ( y ) i ff x and y are extensionally equal as interpreted under T . � 21

  57. Characteristic Relations A sequence of relations R T is called a characteristic relation of a data type T, if for every x : T and y : T , R T ( x ) = R T ( y ) i ff x and y are extensionally equal as interpreted under T . • R mem and R ob are the characteristic relations of queue � 21

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend