Cursor·Software Engineer·Onsite - System Design / Architecture
- Design an in-memory key-value database that supports transactional reads and writes, exposing begin, get, set, commit, and rollback operations.
- How does your design handle two transactions that concurrently write to the same key?
- How would you handle a read-write race where two transactions read stale values and then swap those values between two keys?
- What isolation level should transactions provide, and what are the trade-offs between serializable isolation, snapshot isolation, and weaker guarantees?
- How would you support reads outside of any transaction context?
- How would you prevent long-running transactions from making commit validation increasingly expensive over time?
- How would you write a test to reliably reproduce the two-key swap race condition?
- What changes would be needed to make this database durable?
“I started with a simple map and a per-transaction write buffer, which felt right, but I underestimated how quickly the interviewer would push on isolation.”