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
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.

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
32 practiced

An analytical job needs to read operational tables while writes are continuously happening against them. Which isolation level would you choose for the read job, and why? What goes wrong if you pick the wrong one, and what alternatives exist to get a consistent view without blocking the OLTP writers?

HardTechnical
36 practiced

Production is showing an increasing frequency of deadlocks between two tables during nightly batch jobs. Describe how you would diagnose the root cause using DB diagnostics and logs, how to reproduce and test in staging, short-term mitigations to stop the incident, and long-term fixes including transaction redesign or indexing improvements.

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.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.