Transactions, Concurrency Control, and Isolation Levels Questions
How databases manage concurrent access: ACID transactions, isolation levels and the anomalies they permit (dirty/non-repeatable/phantom reads), locking, and optimistic versus pessimistic concurrency. Covers deadlock handling and choosing an isolation level for a workload. Essential for correctness in any multi-user database system.
Explain ACID and BASE consistency models in the context of transactional and distributed databases. For each property (Atomicity, Consistency, Isolation, Durability) give a short definition and typical implementation considerations. Then explain what BASE (Basically Available, Soft state, Eventual consistency) means and provide two production scenarios where BASE is acceptable and two where ACID is required. Discuss how these models influence database selection and pipeline design.
Explain how PostgreSQL's MVCC (Multi-Version Concurrency Control) works: row versioning, xmin/xmax, transaction snapshots, and why VACUUM is necessary. Discuss how long-running transactions interact with MVCC and the risk of transaction ID wraparound.
Demonstrate how to implement an UPSERT pattern in PostgreSQL using INSERT ... ON CONFLICT DO UPDATE. Show sample SQL that upserts into an inventory table (sku, qty, last_seen). Discuss concurrency implications, what unique index you need for the conflict target, and how to avoid race conditions during high parallelism.
Explain transaction isolation levels (READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE) and the read phenomena (dirty read, non-repeatable read, phantom). For an analytical ETL job that reads operational tables while writes are ongoing, which isolation level would you choose and why? Suggest alternatives to guarantee consistency without blocking OLTP.
Two services (orders and payments) must each update their own database as part of one business operation. Compare Two-Phase Commit (2PC) vs Saga pattern. Describe how each works, operational complexity, failure modes, compensating transactions, idempotency requirements, and monitoring needs. For a high-scale microservices environment which would you choose and why?
Unlock Full Question Bank
Get access to all 9 Transactions, Concurrency Control, and Isolation Levels interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.