Lecture 05
Lecture 05
Next:
• Replication Control = how to handle operations (or transactions) when there
are objects are stored at multiple servers, with or without replication
Replication: What and Why
2. Replication Consistency
– All clients see single consistent copy of data, in spite of replication
– For transactions, guarantee ACID (atomicity, consistency, isolation, and durability)
Replication Transparency
Replicas of an
Front ends Replica 1 object O
provide replication
transparency
Client Front End
Replica 2
Client
Front End
Client Replica 3
Requests
(replies flow opposite)
Replication Consistency
Client
Front End
Client Replica 3
Requests
(replies flow opposite)
Active Replication
Multicast
Front ends Replica 1 inside
provide replication Replica group
transparency
Client Front End
Replica 2
Client
Front End
Client Replica 3
Requests
(replies flow opposite)
Active Replication Using Concepts You’ve Learnt earlier
•
Next
Server 1
Transaction T Object A
write(A,1);
write(B,2); Object B
… .
write(Y, 25); .
write(Z, 26); .
commit
Server 13
Object Y
Object Z
Transactions with Distributed Servers
Coordinator Server 1
Transaction T Server Object A
write(A,1);
.
write(B,2); Object B
.
… . .
write(Y, 25); .
write(Z, 26); .
commit
• Special server called “Coordinator” Server 13
Object Y
initiates atomic commit
• Tells other servers to either
Object Z
commit or abort
One-phase Commit: Issues
• Server may crash before receiving commit message, with some updates still in
memory
Two-phase Commit
Coordinator
…
Server Server 1 Server 13
Prepare
Two-phase Commit
Coordinator
…
Server Server 1 Server 13
Prepare
• Save updates to disk
• Respond with “Yes” or “No”
Two-phase Commit
Coordinator
…
Server Server 1 Server 13
Prepare
• Save updates to disk
• Respond with “Yes” or “No”
If any
“No” vote Abort
or timeout
before all
(13) votes
Two-phase Commit
Coordinator
…
Server Server 1 Server 13
Prepare
• Save updates to disk
• Respond with “Yes” or “No”
All (13)
“Yes” Commit
votes
received
within
timeout?
Two-phase Commit
Coordinator
…
Server Server 1 Server 13
Prepare
• Save updates to disk
• Respond with “Yes” or “No”
All (13)
“Yes” Commit
votes • Wait! Can’t commit or abort
received before receiving next message!
within
timeout?
Two-phase Commit
Coordinator
…
Server Server 1 Server 13
Prepare
• Save updates to disk
• Respond with “Yes” or “No”
All (13)
“Yes” Commit
votes • Commit updates from disk
received to store
within
OK
timeout?
Failures in Two-phase Commit
Atomic Commit
• Can instead use Paxos to decide whether to commit a transaction or not
• But need to ensure that if any server votes No, everyone aborts
Ordering updates
• Paxos can also be used by replica group (for an object) to order all updates –
iteratively do:
– Server proposes message for next sequence number
– Group reaches consensus (or not)
Summary