Question presented to candidate: "What are transaction isolation levels? Name them, tell me which problems each one prevents, and tell me what your database uses by default and why it is not the strictest one."
What a strong answer should cover:
- Isolation is a dial between correctness and concurrency: the stricter the level, the more the database must block or abort concurrent transactions
- The three read phenomena the SQL standard uses: dirty read, non-repeatable read, phantom read β and the four levels defined by which of them they allow (READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE)
- Anomalies the standard table misses: lost update and write skew; only SERIALIZABLE rules out all of them
- Real defaults: PostgreSQL, SQL Server and Oracle use READ COMMITTED, MySQL InnoDB uses REPEATABLE READ, SQLite is serializable; engines may implement a level more strictly than the standard (PostgreSQL treats READ UNCOMMITTED as READ COMMITTED)
- Implementation: locks versus MVCC snapshots, and how to set the level per transaction
Code / implementation expected: Optional β a two-session timeline showing one anomaly, and the syntax to set a level for one transaction.
Schema used by the examples: