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.

HardTechnical
34 practiced

Compare optimistic and pessimistic concurrency control for two different write paths against the same database: (A) an hourly batch ETL job that writes many rows into shared reporting tables, and (B) an interactive UI where multiple users make small, frequent edits to shared metadata records. Which approach fits each path better, and why? Discuss locking, throughput, and how you would resolve conflicts in each case.

EasyTechnical
31 practiced

What is a database transaction, and why do COMMIT and ROLLBACK matter for keeping data correct? Walk through a concrete example, such as a batch data-load job, where a transaction boundary prevents partial or inconsistent data from landing in the table.

HardTechnical
41 practiced

Explain how a distributed deadlock can arise in a sharded transactional system, where a single transaction may need to hold locks on resources across more than one shard. How would you detect that one has occurred, and how would you resolve it once you have? Then discuss the trade-off between preventing distributed deadlocks outright and relying on detection and recovery instead, including when you would lean toward one approach over the other.

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

For each of the following anomalies: dirty read, non-repeatable read, phantom read, lost update, and write skew, give a minimal example with two concurrent transactions that demonstrates it, and state which standard SQL isolation level is the weakest one that prevents it.

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.