Transactions, Concurrency Control, and Isolation Levels Questions

How a database engine manages concurrent access from multiple transactions: ACID guarantees (atomicity, consistency, isolation, durability), the standard isolation levels (read uncommitted, read committed, repeatable read, serializable) and the anomalies they permit or prevent (dirty reads, non-repeatable reads, phantom reads, lost updates, write skew), pessimistic locking versus optimistic concurrency control, deadlock detection and handling (including a single transaction that holds locks across more than one shard), and choosing an isolation level for a given workload (for example OLTP writes versus reporting reads). Also covers MVCC as the mechanism that delivers these guarantees, including snapshot isolation versus true serializability and the version cleanup (vacuum) MVCC requires to control table and index bloat from old row versions. Does not cover correctness across separate databases or services, such as two-phase commit, distributed consensus, or replication and sharding topology design.

MediumTechnical
43 practiced

Multiple worker processes need to increment a shared counter concurrently, for example a daily_user_counts(day, user_count) table. A naive read-then-update (SELECT the count, then UPDATE it to count + 1) loses updates under load. Walk through why that happens, propose a safe way to perform the increment, and discuss the performance and consistency trade-offs of your approach.

MediumTechnical
37 practiced

Dirty read, non-repeatable read, phantom read, and write skew: for each anomaly, give a short SQL example with two concurrent transactions that demonstrates it, and recommend an isolation level or pattern that would prevent it in a banking-style system that aggregates account balances.

MediumTechnical
43 practiced

Walk through the SQL isolation levels: READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE. For each level, describe which anomalies it prevents (dirty reads, non-repeatable reads, phantom reads), and give a short SQL snippet or scenario that demonstrates one anomaly.

MediumTechnical
36 practiced

Compare optimistic and pessimistic concurrency control for a high-traffic inventory system with frequent stock transfers and purchases, such as a flash-sale checkout or a ticket-booking platform. Which strategy would you choose and why? Discuss version checks and retry loops, locking and the deadlock risk it introduces, and what each approach does to the user experience under contention.

HardTechnical
39 practiced

Postgres and MySQL InnoDB both offer a REPEATABLE READ isolation level, but they do not behave identically under it. Explain what REPEATABLE READ actually guarantees in each engine, whether either one can still produce a phantom read at that level, and how each engine's SERIALIZABLE differs in how it is implemented. Why does this matter if you are migrating an application from one engine to the other?

Unlock Full Question Bank

Get access to all 24 Transactions, Concurrency Control, and Isolation Levels interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.