17. Transactions and Locking
Interview questions
Interview questions (with the counter-questions you'll get)
Q1. What is a transaction, and what does ACID guarantee?
They're testing: fundamentals with depth.
Think about your answer first, then open it.
Q2. How do you stop two users booking the last seat?
They're testing: the most common concurrency question.
Think about your answer first, then open it.
Q3. Explain the isolation levels and the anomalies they prevent.
They're testing: precise knowledge.
Think about your answer first, then open it.
Q4. Pessimistic vs optimistic locking: when do you use each?
They're testing: trade-off thinking.
Think about your answer first, then open it.
Q5. What is a deadlock, and how do you handle it?
They're testing: operational understanding.
Think about your answer first, then open it.
Q6. How do you handle a transaction that spans multiple services?
They're testing: microservices realism.
Think about your answer first, then open it.
Q7. How does two-phase commit work, and what's its weakness?
They're testing: a classic protocol.
Think about your answer first, then open it.
Q8. How would you implement a distributed lock, and what can go wrong?
They're testing: depth beyond "use Redis".
Think about your answer first, then open it.
Q9. How do seat holds work in a ticketing system?
They're testing: applying concepts to a classic design.
Think about your answer first, then open it.
Q10. You see the stock of a product go negative in production. How do you investigate and fix it?
They're testing: debugging concurrency in real life.
Think about your answer first, then open it.