Primary-Backup Protocol
CSE 452 Spring 2023
Roadmap
5 rules of Primary-Backup
Design Docs
General Flow
Client
Primary
Backup
View Server
Pool of Idle Servers
What messages do the arrows represent?
The 5 Sacred Scrolls of Primary-Backup
Rules:
Rule 1: What if the new Primary was not in the previous view?
Client
Server A
{foo: bar}
Server B
{foo: bar}
Server C
{}
Server D
{}
Append(foo->bar)
Append(foo->bar)
AppendRes(bar)
AppendRes(bar)
View 2
Primary: A
Backup: B
Rule 1: What if the new Primary was not in the previous view?
Client
Server A
{foo: bar}
Server B
{foo: bar}
Server C
{}
Server D
{}
View 3
Primary: C
Backup: D
Get(foo)
KeyNotFound()
Get(foo)
KeyNotFound()
Rule 1: Solution + Takeaway
The new primary MUST have been in the previous view
View i
Primary: A
Backup: B
View i+1
Primary: A
Backup: NULL
View i
Primary: A
Backup: B
View i+1
Primary: B
Backup: NULL
View i
Primary: A
Backup: B
View i+1
Primary: B
Backup: A
Some Possible? Transitions
Rule 1: Solution + Takeaway
The new primary MUST have been in the previous view
View i
Primary: A
Backup: B
View i+1
Primary: A
Backup: NULL
View i
Primary: A
Backup: B
View i+1
Primary: B
Backup: NULL
View i
Primary: A
Backup: B
View i+1
Primary: B
Backup: A
Some Possible? Transitions
Rule 1: Solution + Takeaway
The new primary MUST have been in the previous view
View i
Primary: A
Backup: B
View i+1
Primary: A
Backup: NULL
View i
Primary: A
Backup: B
View i+1
Primary: B
Backup: NULL
View i
Primary: A
Backup: B
View i+1
Primary: B
Backup: A
Some Possible? Transitions
Rule 1: Solution + Takeaway
The new primary MUST have been in the previous view
View i
Primary: A
Backup: B
View i+1
Primary: A
Backup: NULL
View i
Primary: A
Backup: B
View i+1
Primary: B
Backup: NULL
View i
Primary: A
Backup: B
View i+1
Primary: B
Backup: A
Some Possible? Transitions
Rules:
Rule 2: What if we did not forward requests before executing them?
Client
Server A
{foo: bar}
Server B
{}
Server C
{}
Append(foo->bar)
Append(foo->bar)
AppendOk(bar)
View 2
Primary: A
Backup: B
Rule 2: What if we did not forward requests before executing them?
Client
Server A
{foo: bar}
Server B
{}
Server C
{}
Get(foo)
View 3
Primary: B
Backup: C
KeyNotFound
Get(foo)
KeyNotFound
Rule 2: Solution
Primary must wait for backup to accept/execute each op before doing op and replying to client
Rule 2: How does this fix anything?!?
Client
Server A
{}
Server B
{}
Server C
{}
Append(foo->bar)
Append(foo->bar)
AppendOk(bar)DOES NOT EXIST!!
View 2
Primary: A
Backup: B
Rule 2: Another (interesting) issue
Server C
{}
View 2
Primary: A
Backup: B
Client
Server A
{foo: bar}
Server B
{foo: bar}
Append(foo->bar)
Append(foo->bar)
AppendRes(bar)
AppendRes(bar)
View 2
Primary: A
Backup: B
View 2
Primary: A
Backup: B
View 2
Primary: A
Backup: B
Rule 2: What if we did not forward requests before executing them?
Client
Server A
{foo: barbaz}
Server B
{foo: bar}
Server C
{foo: bar}
Append(foo->baz)
View 3
Primary: B
Backup: C
AppendRes(barbaz)
Suppose both the client and Server A do not get the new View…
Append(foo->baz)
View 2
Primary: A
Backup: B
View 2
Primary: A
Backup: B
View 3
Primary: B
Backup: C
Rule 2: What if we did not forward requests before executing them?
Client
Server A
{foo: barbaz}
Server B
{foo: bar}
Server C
{foo: bar}
View 3
Primary: B
Backup: C
When the client eventually
gets the new view…
Get(foo)
GetRes(bar)
GetRes(bar)
Get(foo)
View 3
Primary: B
Backup: C
View 3
Primary: B
Backup: C
Rule 2: How does this fix anything?!?
Client
Server A
{foo: bar}
Server B
{foo: bar}
Server C
{foo: bar}
View 3
Primary: B
Backup: C
Suppose both the client and Server A do not get the new View…
Client never gets a response :)
Append(foo->baz)
Append(foo->baz)
Rule 2: Takeaway
Forwarding!
Hint: You may want to use a timer to ensure forwarded methods get processed
Rules:
Rule 3: Problem & Solution
View 2
Primary: A
Backup: B
View 3
Primary: B
Backup: C
View 4
Primary: C
Backup: D
View 5
Primary: D
Backup: B
Forwarded
Hint: Have the view number on all messages
(Be careful of state-transfer messages)
Rules:
Rule 4: What if a non-primary responds to a client?
Server C
{}
View 4
Primary: B
Backup: null
Client
Server A
{}
Server B
{}
Put(a->bar)
View 2
Primary: A
Backup: B
View 4
Primary: B
Backup: null
View 4
Primary: B
Backup: null
View 3
Primary: B
Backup: C
Rule 4: What if a non-primary responds to a client?
Server C
{}
View 4
Primary: B
Backup: null
Client
Server A
{a:bar}
Server B
{}
Put(a->bar)
View 2
Primary: A
Backup: B
View 4
Primary: B
Backup: null
View 4
Primary: B
Backup: null
View 3
Primary: B
Backup: C
Rule 4: What if a non-primary responds to a client?
Server C
{}
View 4
Primary: B
Backup: null
Client
Server A
{a:bar}
Server B
{}
PutOk()
View 2
Primary: A
Backup: B
View 4
Primary: B
Backup: null
View 4
Primary: B
Backup: null
View 3
Primary: B
Backup: C
Rule 4: What if a non-primary responds to a client?
Server C
{}
View 4
Primary: B
Backup: null
Client
Server A
{a:bar}
Server B
{}
View 4
Primary: B
Backup: null
View 4
Primary: B
Backup: null
View 4
Primary: B
Backup: null
View 3
Primary: B
Backup: C
Rule 4: What if a non-primary responds to a client?
Server C
{}
View 4
Primary: B
Backup: null
Client
Server A
{a:bar}
Server B
{}
View 4
Primary: B
Backup: null
View 4
Primary: B
Backup: null
View 4
Primary: B
Backup: null
View 3
Primary: B
Backup: C
Get(a)
Rule 4: What if a non-primary responds to a client?
Server C
{}
View 4
Primary: B
Backup: null
Client
Server A
{a:bar}
Server B
{}
View 4
Primary: B
Backup: null
View 4
Primary: B
Backup: null
View 4
Primary: B
Backup: null
View 3
Primary: B
Backup: C
KeyNotFound()
Rule 4: Takeaway
Rules:
Recap: State Transfer
Recap: State Transfer (Subtle details)
Rule 5: What if we processed requests during state transfer?
Primary
Backup
StateTransfer((“a” -> “foo”))
“a” -> “foo”
Client 1
Put(“a”, “bar”)
Put(“a”, “bar”)
Put(“a”, “bar”)
“a” -> “foo”
“a” -> “bar”
“a” -> “bar”
StateTransferAck
Rule 5: Takeaway
Questions So Far?
Design Doc Tips
Why Design Docs?
Things to Design
Good Design Doc Practices
Example Protocol for Atleast Once RPC (Lab 1 Part 2)
Example Protocol for Atleast Once RPC (Lab 1 Part 2)
Example Protocol for Atleast Once RPC (Lab 1 Part 2)
Example Protocol for Atleast Once RPC (Lab 1 Part 2)
Where to Start
Analysis: Processing Multiple Requests Simultaneously
Primary
Backup
Put(“a”, “foo”)
Put(“a”, “foo”)
“a” -> “foo”
Client 1
Put(“a”, “foo”)
Client 2
Put(“a”, “bar”)
Put(“a”, “bar”)
Put(“a”, “bar”)
“a” -> “bar”
“a” -> “bar”
“a” -> “foo”