Update Parallelism April 30, 2018 1 HW 3 Posted 2 Parallelism - - PowerPoint PPT Presentation

update parallelism
SMART_READER_LITE
LIVE PREVIEW

Update Parallelism April 30, 2018 1 HW 3 Posted 2 Parallelism - - PowerPoint PPT Presentation

Update Parallelism April 30, 2018 1 HW 3 Posted 2 Parallelism Models Option 4: Shared Nothing in which all communication is explicit. CPU Memory Disk Well be talking about shared nothing today. Other models are easier


slide-1
SLIDE 1

Update Parallelism

April 30, 2018

1

slide-2
SLIDE 2

HW 3 Posted

2

slide-3
SLIDE 3

Parallelism Models

3

CPU Memory Disk …

We’ll be talking about “shared nothing” today. Other models are easier to work with.

Option 4: “Shared Nothing” in which all communication is explicit.

slide-4
SLIDE 4

Data Parallelism

4

A A A C B A

Replication Partitioning

(needed for safety)

slide-5
SLIDE 5

Updates

  • Non-Serializable Schedules
  • One Compute Node Fails
  • A Communication Channel Fails
  • Messages are

5

What can go wrong?

Node 1

T1: W(X) T2: W(X) T2: W(Y) T1: W(Y)

slide-6
SLIDE 6

Updates

  • Non-Serializable Schedules
  • One Compute Node Fails
  • A Communication Channel Fails
  • Messages are

5

What can go wrong?

Node 1

T1: W(X) T2: W(X) T2: W(Y) T1: W(Y)

X

slide-7
SLIDE 7

Updates (in Parallel)

  • Non-Serializable Schedules
  • One Compute Node Fails
  • A Communication Channel Fails
  • Messages delivered out-of-order

6

What can go wrong?

Node 1 Node 2

slide-8
SLIDE 8

Updates (in Parallel)

  • Non-Serializable Schedules
  • One Compute Node Fails
  • A Communication Channel Fails
  • Messages delivered out-of-order

6

What can go wrong?

Node 1 Node 2

slide-9
SLIDE 9

Updates (in Parallel)

  • Non-Serializable Schedules
  • One Compute Node Fails
  • A Communication Channel Fails
  • Messages delivered out-of-order

7

What can go wrong?

Node 1 Node 2

slide-10
SLIDE 10

Updates (in Parallel)

  • Non-Serializable Schedules
  • One Compute Node Fails
  • A Communication Channel Fails
  • Messages delivered out-of-order

7

What can go wrong?

Node 1 Node 2

slide-11
SLIDE 11

Updates (in Parallel)

  • Non-Serializable Schedules
  • One Compute Node Fails
  • A Communication Channel Fails
  • Messages delivered out-of-order

8

What can go wrong?

Node 1 Node 2

slide-12
SLIDE 12

Updates (in Parallel)

  • Non-Serializable Schedules
  • One Compute Node Fails
  • A Communication Channel Fails
  • Messages delivered out-of-order

8

What can go wrong?

Node 1 Node 2

X Y Y X

slide-13
SLIDE 13

Updates (in Parallel)

  • Non-Serializable Schedules
  • One Compute Node Fails
  • A Communication Channel Fails
  • Messages delivered out-of-order

9

What can go wrong?

slide-14
SLIDE 14

Updates (in Parallel)

  • Non-Serializable Schedules
  • One Compute Node Fails
  • A Communication Channel Fails
  • Messages delivered out-of-order

9

What can go wrong? Classical Xacts

slide-15
SLIDE 15

Updates (in Parallel)

  • Non-Serializable Schedules
  • One Compute Node Fails
  • A Communication Channel Fails
  • Messages delivered out-of-order

9

What can go wrong? Classical Xacts “Partitions”

slide-16
SLIDE 16

Updates (in Parallel)

  • Non-Serializable Schedules
  • One Compute Node Fails
  • A Communication Channel Fails
  • Messages delivered out-of-order

9

What can go wrong? Classical Xacts “Partitions” Consensus

slide-17
SLIDE 17

Data Parallelism

10

A A A C B A

Replication Partitioning

(needed for safety)

slide-18
SLIDE 18

Simple Consensus

11

A A B B

Node 1 Node 2

Master Slave

Y X Y X

“Safe” … but Node 1 is a bottleneck.

slide-19
SLIDE 19

Simpl-ish Consensus

12

A A

Node 1 Node 2

Master for A Master for B Node 2 agrees to Node 1’s order for A. Node 1 agrees to Node 2’s order for B.

B B

Y X Y X

slide-20
SLIDE 20

Partitions

13

Node 1 Node 2 Node 1

From Node 1’s perspective, these are the same! Channel Failure Node Failure

Node 2

slide-21
SLIDE 21

Failure Recovery

  • Node Failure
  • The node restarts and resumes serving requests.
  • Channel Failure
  • Node 1 and Node 2 regain connectivity.

14

slide-22
SLIDE 22

Partitions

15

Node 1 Node 2

A=1 B=5 A=1 B=5

slide-23
SLIDE 23

Partitions

16

Node 1

Option 1: Node 1 takes over

Node 2

A=1 B=5

slide-24
SLIDE 24

Partitions

17

Node 1

Option 1: Node 1 takes over

Node 2

Node 2 is down. I control A & B now!

A=1 B=5

slide-25
SLIDE 25

Partitions

18

Node 1

Option 1: Node 1 takes over

Node 2

Node 2 is down. I control A & B now! A = 2 B = 6

A=2 B=6

slide-26
SLIDE 26

Partitions

19

Node 1

Option 1: Node 1 takes over

Node 2

A=2 B=6 A=2 B=6

slide-27
SLIDE 27

Partitions

20

Node 1

Option 1: Node 1 takes over

Node 2

A=1 B=5 A=1 B=5

slide-28
SLIDE 28

Partitions

21

Node 1

Option 1: Node 1 takes over

Node 2

A=1 B=5 A=1 B=5

Node 2 is down. I control A & B now!

slide-29
SLIDE 29

Partitions

22

Node 1

Option 1: Node 1 takes over

Node 2

A=2 B=6 A=1 B=5

Node 2 is down. I control A & B now! A = 2 B = 6

slide-30
SLIDE 30

Partitions

23

Node 1

Option 1: Node 1 takes over

Node 2

A=2 B=6 A=1 B=5 INCONSISTENCY!

slide-31
SLIDE 31

Partitions

24

Node 1 Node 2

Option 2: Wait

slide-32
SLIDE 32

Partitions

25

Node 1 Node 2

A = 2 B = 6

Option 2: Wait

slide-33
SLIDE 33

Partitions

26

Node 1 Node 2

I can’t talk to Node 2 Let me wait! A = 2 B = 6

Option 2: Wait

slide-34
SLIDE 34

Partitions

27

Node 1 Node 2

I can’t talk to Node 2 Let me wait! A = 2 B = 6

Option 2: Wait

slide-35
SLIDE 35

Partitions

28

Node 1 Node 2

I can’t talk to Node 2 Let me wait! A = 2 B = 6 All set

Option 2: Wait

slide-36
SLIDE 36

Partitions

29

Node 1 Node 2

Option 2: Wait

slide-37
SLIDE 37

Partitions

29

Node 1

Option 2: Wait

slide-38
SLIDE 38

Partitions

30

Node 1

I can’t talk to Node 2 Let me wait! A = 2 B = 6

Option 2: Wait

slide-39
SLIDE 39

Partitions

31

Node 1

I can’t talk to Node 2 Let me wait! A = 2 B = 6 Still waiting…

Option 2: Wait

slide-40
SLIDE 40

Partitions

32

Option 1: Assume Node Failure All data is available… but at risk of inconsistency. Option 2: Assume Connection Failure All data is consistent… but unavailable

slide-41
SLIDE 41

33

C A P

  • n

s i s t e n c y v a i l a b i l i t y

  • r
  • r

a r t i t i

  • n

Traditionally: Pick any 2 T

  • l

e r a n c e

slide-42
SLIDE 42

34

C A P

  • r

during

  • n

s i s t e n c y v a i l a b i l i t y a r t i t i

  • n

s I prefer this phrasing

slide-43
SLIDE 43

Simpl-ish Consensus

35

A A

Node 1 Node 2

Master for A Master for B Node 2 agrees to Node 1’s order for A. Node 1 agrees to Node 2’s order for B.

B B

Y X Y X

slide-44
SLIDE 44

Simpl-ish Consensus

36

A A

Node 1 Node 2

Master for A Master for B What if we need to coordinate between A & B?

B B

Y X Y X Withdraw $1000 from A Deposit $1000 into B

slide-45
SLIDE 45

Naive Commit

37

Node 1 Node 2 Coordinator W(A,B)

slide-46
SLIDE 46

Naive Commit

37

Node 1 Node 2 Coordinator Safe to Commit? W(A,B)

slide-47
SLIDE 47

Naive Commit

37

Node 1 Node 2 Coordinator ACK Safe to Commit ? W(A,B)

slide-48
SLIDE 48

Naive Commit

37

Node 1 Node 2 Coordinator ACK Safe to Commit W(A,B)

slide-49
SLIDE 49

38

That packet sure does look tasty…

slide-50
SLIDE 50

Naive Commit

39

Node 1 Node 2 Coordinator W(A,B) ACK

Is it safe to abort?

slide-51
SLIDE 51

Naive Commit

40

Node 1 Node 2 Coordinator ACK ACK

What now?

W(A,B)

slide-52
SLIDE 52

Naive Commit

41

Node 1 Node 2 Coordinator W(A) ACK

How do we know Node 2 even still exists?

slide-53
SLIDE 53

2-Phase Commit

  • One site selected as a coordinator.
  • Initiates the 2-phase commit process.
  • Remaining sites are subordinates.
  • Only one coordinator per xact.
  • Different xacts may have different coordinators.

42

slide-54
SLIDE 54

Assumptions

  • Undo/Redo Logging at Participants
  • Participants can Abort an Xact at any time
  • Participants can recover from a crash
  • Redo Logging at Coordinator
  • Coordinator can recover from a crash
  • All logs replicated (to recover from hard failures)

43

slide-55
SLIDE 55

Phase 1 - Prepare

44

Coordinator Node 1 Node 2

slide-56
SLIDE 56

Phase 1 - Prepare

45

Coordinator Node 1 Node 2 “Prepare”

slide-57
SLIDE 57

Phase 1 - Prepare

46

Coordinator Node 1 Node 2 “Prepare” “Commit” “Commit”

slide-58
SLIDE 58

Phase 1 - Prepare

47

Coordinator Node 1 Node 2 “Prepare”

We are go for Commit

“Commit” “Commit”

slide-59
SLIDE 59

Phase 2 - Commit

48

Coordinator Node 1 Node 2 “Prepare” “Commit”

We are go for Commit

“Commit” “Commit”

slide-60
SLIDE 60

Phase 2 - Commit

49

Coordinator Node 1 Node 2 “Prepare” “Commit” “ACK” “ACK”

ACKs received Commit successful We are go for Commit

“Commit” “Commit”

slide-61
SLIDE 61

Aborting

50

Coordinator Node 1 Node 2 “Prepare”

Commit Canceled

“Abort” “ACK” “ACK”

ACKs received Abort successful

“Commit” “Abort”

If any participant aborts in Phase 1, everyone aborts.

slide-62
SLIDE 62

Guarantees

51

Coordinator Node 1 Node 2 “Prepare” “Commit” “ACK” “ACK”

ACKs received Commit successful We are go for Commit

“Commit” “Commit”

A Node “Commit” means the node is able to commit. A Coordinator “Commit” means the transaction must commit.

slide-63
SLIDE 63

Guarantees

52

Coordinator Node 1 Node 2 “Prepare” “Commit” “ACK” “ACK”

ACKs received Commit successful We are go for Commit

“Commit” “Commit”

Once a node commits, the xact is still not committed yet. However the node must avoid breaking the commit.

slide-64
SLIDE 64

Failure Modes

53

Coordinator Node 1 Node 2 “Prepare” “Commit”

slide-65
SLIDE 65

Failure Modes

53

Coordinator Node 1 Node 2 “Prepare” “Commit”

Prepare unreceived and unacknowledged: Coordinator (1) Retries, or (2) Aborts

slide-66
SLIDE 66

Failure Modes

54

Coordinator Node 1 Node 2 “Prepare” “Commit”

CRASH!

slide-67
SLIDE 67

Failure Modes

54

Coordinator Node 1 Node 2 “Prepare” “Commit”

Node 2 crashes before responding: Restart and continue as a dropped packet

CRASH!

slide-68
SLIDE 68

Failure Modes

55

Coordinator Node 1 Node 2 “Prepare” “Commit” “Commit”

slide-69
SLIDE 69

Failure Modes

55

Coordinator Node 1 Node 2 “Prepare” “Commit” “Commit”

Node “Commit” unreceived: (1) Re-sent “Prepare” can be ignored. (2) Node still able to abort.

slide-70
SLIDE 70

Failure Modes

56

Coordinator Node 1 Node 2 “Prepare” “Commit” “Commit”

CRASH!

slide-71
SLIDE 71

Failure Modes

56

Coordinator Node 1 Node 2 “Prepare” “Commit” “Commit”

Node 2 crashes after responding: Restart from log

CRASH!

slide-72
SLIDE 72

Failure Cases

57

Coordinator Node 1 Node 2 “Prepare” “Commit” “ACK”

We are go for Commit

“Commit” “Commit”

slide-73
SLIDE 73

Failure Cases

57

Coordinator Node 1 Node 2 “Prepare” “Commit” “ACK”

We are go for Commit

“Commit” “Commit”

Coordinator “Commit” unreceived: Commit must happen, coordinator resends

slide-74
SLIDE 74

Failure Cases

58

Coordinator Node 1 Node 2 “Prepare” “Commit” “ACK”

We are go for Commit

“Commit” “Commit”

CRASH!

slide-75
SLIDE 75

Failure Cases

58

Coordinator Node 1 Node 2 “Prepare” “Commit” “ACK”

We are go for Commit

“Commit” “Commit”

Node 2 crash: Restart. Already logged “Commit” message, so all is well.

CRASH!

slide-76
SLIDE 76

Failure Cases

59

Coordinator Node 1 Node 2 “Prepare” “Commit” “ACK” “ACK”

We are go for Commit

“Commit” “Commit”

slide-77
SLIDE 77

Failure Cases

59

Coordinator Node 1 Node 2 “Prepare” “Commit” “ACK” “ACK”

We are go for Commit

“Commit” “Commit”

Node “Ack” unreceived: Ok. Resent “Commit” ignored by node

slide-78
SLIDE 78

Failure Cases

60

Coordinator Node 1 Node 2 “Prepare” “Commit” “ACK”

We are go for Commit

“Commit” “Commit”

CRASH!

“ACK”

slide-79
SLIDE 79

Failure Cases

60

Coordinator Node 1 Node 2 “Prepare” “Commit” “ACK”

We are go for Commit

“Commit” “Commit”

Node crash after “Ack”: Ok. Log already recorded commit

CRASH!

“ACK”

slide-80
SLIDE 80

Replication

  • Mode 1: Periodic Backups
  • Copy the replicated data nightly/hourly.
  • Mode 2: Log Shipping
  • Only send changes (replica serves as the log).

61

slide-81
SLIDE 81

Replication

  • Mode 1: Periodic Backups
  • Copy the replicated data nightly/hourly.
  • Mode 2: Log Shipping
  • Only send changes (replica serves as the log).

61

slide-82
SLIDE 82

Replication

  • Ensuring durability
  • Ensuring write-consistency under 2PC
  • Ensuring read-consistency without 2PC

62

slide-83
SLIDE 83

Ensuring Durability

63

When is a replica write durable?

slide-84
SLIDE 84

Ensuring Durability

64

Never.

slide-85
SLIDE 85

Ensuring Durability

64

Never. What you should be asking is how much durability do you need?

slide-86
SLIDE 86

Ensuring Durability

65

For N Failures N+1 Replicas (Assuming Failure = Crash)

slide-87
SLIDE 87

Ensuring Write Consistency

66

Coordinator Node 1 “Prepare” “Commit” Node 1 asserts that the commit is durable! What if Node 1 fails?

slide-88
SLIDE 88

Ensuring Write Consistency

67

Coordinator Node 1 Replica “Prepare” “Commit” “Prepare” “Commit”

slide-89
SLIDE 89

Ensuring Write Consistency

67

Coordinator Node 1 Replica “Prepare” “Commit” “Prepare” “Commit” Waiting for Node 1 to replicate is slooooow! Let the coordinator take over!

slide-90
SLIDE 90

Ensuring Write Consistency

68

Coordinator Node 1 Replica “Prepare” “Commit” “Commit”

slide-91
SLIDE 91

Ensuring Write Consistency

68

Coordinator Node 1 Replica “Prepare” Like 2PC… … but better. We may not need to wait for the replica “Commit” “Commit”

slide-92
SLIDE 92

Ensuring Write-Consistency

69

Replica 2 Replica 1 Replica 3

A: Prepare

Coordinator Alice Coordinator Bob

B: Prepare A: Prepare B: Prepare A: Prepare B: Prepare

slide-93
SLIDE 93

Ensuring Write-Consistency

70

Replica 2 Replica 1 Replica 3

Coordinator Alice Coordinator Bob

A: Prepare B: Prepare A: Prepare B: Prepare A: Prepare B: Prepare

slide-94
SLIDE 94

Ensuring Write-Consistency

71

Replica 2 Replica 1 Replica 3

Coordinator Alice Coordinator Bob

B: Prepare B: Prepare A: Prepare

Commit! Commit!

slide-95
SLIDE 95

Ensuring Write-Consistency

72

Majority Vote N Replicas (N/2)+1 Votes Needed

slide-96
SLIDE 96

Ensuring Read Consistency

73

Forget transactions, let’s go back to reads & writes Can we do better than 2PC if we don’t need xacts?

slide-97
SLIDE 97

74

Replica 2 Replica 1 Replica 3

W(A = 3) (1) Alice writes ‘A’

slide-98
SLIDE 98

75

Replica 2 Replica 1 Replica 3

W(A = 3) (1) Alice writes ‘A’ (2) Alice tells Bob

slide-99
SLIDE 99

76

Replica 2 Replica 1 Replica 3

W(A = 3) (1) Alice writes ‘A’ (2) Alice tells Bob (3) Bob reads ‘A’ R(A)

slide-100
SLIDE 100

77

Replica 2 Replica 1 Replica 3

W(A = 42) (1) Alice writes ‘A’ (2) Alice tells Bob (3) Bob reads ‘A’ R(A) What can we do to guarantee that Bob will see the 42?

slide-101
SLIDE 101

Ensuring Read Consistency

78

Approach: Alice and Bob each wait for multiple responses. Alice waits for ‘ack’s Bob waits for read responses. How many responses are required for each?

slide-102
SLIDE 102

79

Replica 2 Replica 1 Replica 3

W(A = 42) R(A) ACK

slide-103
SLIDE 103

80

Replica 2 Replica 1 Replica 3

W(A = 42) R(A) ACK “666”

slide-104
SLIDE 104

81

Replica 2 Replica 1 Replica 3

W(A = 42) R(A) ACK “666”

slide-105
SLIDE 105

82

Replica 2 Replica 1 Replica 3

W(A = 42) R(A) ACK “666”

slide-106
SLIDE 106

Ensuring Read-Consistency

83

Like Majority Vote N Replicas R Replica Reads Needed W Writer Acks Needed R + W > N