Section 2: Lab 2
(Primary Backup)
CSE 452 Spring 2026
Announcements
If you haven’t already...
Add your partner to your GitLab repo specified by following these steps:
Recap 6 Rules:
Why Primary-Backup?
Want to achieve…
Replication!
If primary dies…there’s a backup!
General Flow
Pool of Idle Servers
Client
Primary
Backup
View Server
Request
Forward Request
Forward
Ack
Response
Ping
Ping
Ping
GetView
What messages do they send/receive?
ViewReply (VR)
VR
VR
VR
What’s a view? (in the labs)
The View Server
Receiving and Responding to Pings
Pinging the View Server:
Replying to Pings:
View Server’s reply to a Ping informs the server of the current view
Idle Servers
Primary
Backup
View Server
Ping(i)
Ping(i)
Ping(i)
current view: i
When can the VS move on to a new view?
From start-up view (special case) with no primary/backup:
For any other view (general case):
When can the VS move on to a new view?
View: STARTUP_VIEW_NUM
Primary: null
Backup: null
First view
View: INITIAL_VIEW_NUM
Primary: A
Backup: null
Server A Ping’d View Server
View:
INITIAL_VIEW_NUM + 1
Primary: A
Backup: B
Server B Ping’d View Server
View Server cannot transition to INITIAL_VIEW_NUM + 1 until Primary (A) acknowledges View INITIAL_VIEWNUM
Q: Can View1(primary=A, backup=null) change to View2(primary=B, backup=C) if A died?
How is this done in code?
PingCheckTimer Semantics
PingCheckTimer
PingCheckTimer
S1 ping
S2 ping
Here, at the first PingCheckTimer, S1 and S2 are still considered alive.
Here, at the second PingCheckTimer, S1 is still alive, but since S2 did not ping since the last PingCheckTimer, S2 is considered dead.
0ms
100ms
200ms
“If the ViewServer doesn't receive a Ping from a server since the last PingCheckTimer, it should consider the server to be dead”
For lab 2: Do NOT store timestamps on the view server! Needs to be deterministic for search tests.
(2nd most recent pingcheck timer)
( most recent pingcheck timer)
When can the VS move on to a new view?
View Transition Timeouts (worksheet q2)
Worksheet Q2
View Transition Timeouts
Worksheet Q2
Example Call Flow Diagram
(S1 crash)
Server 1
View Server
Server 2
Ping(0)
View 1 {S1, null}
Ping(0)
View 1 {S1, null}
Ping(1)
View 2 {S1, S2}
Ping(1)
View 2 {S1, S2}
Ping(2)
View 2 {S1, S2}
S1 crashes
Ping(2)
View 3 {S2, null}
Server 3
Ping(0)
Ping(3)
View 4 {S2, S3}
View 3 {S2, null}
*
* S1 sends application state to S2 and gets an ack back before Ping(2), acknowledging the view
Call flow Diagram (worksheet q3)
It is acknowledged at point e.
Worksheet Q3
Example Call Flow Diagram
(S2 crash)
Server 1
View Server
Server 2
Ping(0)
View 1 {S1, null}
Ping(0)
View 1 {S1, null}
Ping(1)
View 2 {S1, S2}
Ping(1)
View 2 {S1, S2}
Ping(2)
View 2 {S1, S2}
Server 3
Ping(0)
View 4 {S1, S3}
*
* S1 sends application state to S2 and gets an ack back before Ping(2), acknowledging the view
S2 crashes
Ping(2)
View 3 {S1, null}
Ping(3)
View 4 {S1, S3}
**
** Same as * except with S3 instead of S2 and Ping(4) (which isn’t drawn)
View 3 {S1, null}
Ping(3)
Call flow Diagram (worksheet q4)
Worksheet Q4
Primary and Backup
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”
Remember the rules!
Questions So Far?
Design Doc Tips
Why Design Docs?
Things to Design
Good Design Doc Practices
Example Protocol for At least Once RPC (Lab 1 Part 2)
Example Protocol for At least Once RPC (Lab 1 Part 2)
Example Protocol for At least Once RPC (Lab 1 Part 2)
Example Protocol for At least Once RPC (Lab 1 Part 2)
Where to Start
Lab 2 Debugging Tips
General tips
State Transfer - Things to keep in mind
Additional Lab 2 hints/help
Even more Lab 2 hints
Some debugging tips
| Run | Search |
Invariant Violations | -g FINER &> log.txt → might need to print out multiple runs if issue does not appear every time (printlns also helpful) | Visual Debugger → retrace steps that led to the invariant violation |
Liveness Violation or Timeout | -g FINER &> log.txt → look for patterns in log file (printlns also helpful) | Visual Debugger → try to drive system towards goal (under the constraints of the test) |
Some debugging tips
Run Test Debugging: Logging
Search Debugging: Invariant Violations
Search Debugging: Liveness Violations
Search Debugging: Liveness Violations
Other common issues
Pro Tips
1. If you’re failing test 2.19 and only test 2.19, try removing maps in the view server if you have any
Could not find state matching "All clients' workloads finished"
Some other tips for search tests
Could not find state matching "All clients' workloads finished"
More Tips
If you get “not all clients’ results are the same”
GetResult(“x”, “xy”)
GetResult(“x”, “yx”)
If you’re timing out on test 2.14/2.15
Try putting print statements on view changes and when you handle results on the clients as a point of departure for debugging
You can reply right away to alreadyExecuted commands, so you don’t need to forward it to the backup and get an ack back