Layer 3 · Go deeper · 7 min
Go deeper
Size it, build it, then make the calls an interviewer will push you on.
Back of the envelope
Size it up
Tap through each step of the arithmetic.
How many transactions a second can one hot row take?
Build-up · 6 steps
From two-phase locking to a deadlock
Locking makes conflicting transactions wait. Follow the rules that make it serializable, then the failure that waiting creates and the two ways out.
Step 1 of 6
Shared and exclusive locks
Reads take a shared (S) lock, writes an exclusive (X) lock. Readers can share a row, but a writer waits for every holder, and everyone waits for a writer.
3 interview moments
You’re the candidate
The interviewer pushes on the hard parts. Pick an approach and see how it holds up.
Deep dive 1 of 3
Interviewer
“Tickets for a final go on sale. In the first minute, thousands of buyers chase the same seat rows. How do you guard each seat?”
Your move. Pick an approach:
Deep dive 2 of 3
Interviewer
“Wallet transfers keep failing with deadlock errors under load. Two code paths lock the same accounts in opposite orders. What do you change?”
Your move. Pick an approach:
Deep dive 3 of 3
Interviewer
“Your PostgreSQL app runs at Serializable, and serialization failures (40001) have jumped. What do you do?”
Your move. Pick an approach:
Build-up · 5 steps
Catch write skew with SSI
Snapshot isolation’s only rule for writers is first updater wins. Watch two transactions slip past it by writing different rows, and how SSI notices.
Step 1 of 5
One snapshot each
Meera and Kabir supervise a warehouse at night, and at least one must stay on shift. Each starts a transaction, and each snapshot shows 2 on shift.