Scrivio Interview library
LeadershipPrincipal6 min read · updated 12 November 2026

Lock-based concurrency control dominated databases for decades and was then largely replaced by MVCC with optional locking. Explain why the ecosystem moved, and what this history means for how your organisation should design contention-heavy systems today.

Try it yourself

Isolation levels: what a second read sees

Step through two transactions and see exactly when read committed and repeatable read give different answers.

Read this example as text

T1 at read committed

  1. T1 begins. Transaction T1 starts with isolation level READ COMMITTED. The row holds balance 100.
  2. T1 reads the balance. T1 reads 100. Under read committed each statement looks afresh at what is committed when the statement starts.
  3. T2 changes the row. A second transaction, T2, sets the balance to 150 but has not committed. The database keeps both versions: 100 is still the committed one.
  4. T1 reads again, before T2 commits. T1 reads 100 again. Neither level shows another transaction's uncommitted change, so there is no dirty read. T1 does not wait for T2 either.
  5. T2 commits. T2 commits. The committed balance is now 150.
  6. T1 reads a third time. T1 reads 150. The same query, inside one transaction, returned 100 and then 150. This is a non-repeatable read, and read committed allows it.
  7. T1 commits. T1 ends. A transaction that starts now reads 150 at either level.

T1 read 100, 100, then 150: a non-repeatable read.

T1 at repeatable read

  1. T1 begins. Transaction T1 starts with isolation level REPEATABLE READ. The row holds balance 100.
  2. T1 reads the balance. T1 reads 100. Under repeatable read this first read fixes T1's snapshot: T1 will keep seeing the data as it was committed at this moment.
  3. T2 changes the row. A second transaction, T2, sets the balance to 150 but has not committed. The database keeps both versions: 100 is still the committed one.
  4. T1 reads again, before T2 commits. T1 reads 100 again. Neither level shows another transaction's uncommitted change, so there is no dirty read. T1 does not wait for T2 either.
  5. T2 commits. T2 commits. The committed balance is now 150.
  6. T1 reads a third time. T1 still reads 100. Its snapshot was fixed at its first read, so T2's commit is invisible to it. The read is repeatable.
  7. T1 commits. T1 ends. A transaction that starts now reads 150 at either level.

T1 read 100 three times: its reads were repeatable.

What this example leaves out
  • Modelled on PostgreSQL and MySQL InnoDB, where a plain SELECT reads a snapshot and never waits for a writer.
  • SQL Server's default read committed uses locks instead: there, T1's second read would wait for T2 to finish.
  • Only reads are compared. What happens when T1 also writes the row (a lost update, or an error in PostgreSQL) is not modelled.

The ecosystem moved from pure locking to MVCC because two-phase locking makes readers and writers block each other, which hurt badly once systems mixed long reads with heavy writes; MVCC removed that blocking at the cost of storing and cleaning up old versions. But it also moved some anomalies, notably write skew, onto the application, and locks never went away. For contention-heavy systems today, the lesson is to design data so contention is avoided rather than managed, and to treat the concurrency strategy as a recorded, tested architecture decision.

Why this question is asked

History is useful in architecture when it explains why today's tools behave as they do. The move from locking to MVCC explains why PostgreSQL never blocks a report, why it needs VACUUM, and why our booking code can still double-book at the default isolation level. Interviewers ask senior leaders this to see whether they draw design principles from it rather than nostalgia. In this answer, we will recap pure lock-based concurrency, see why it lost ground, what MVCC changed and what it did not, and then turn the history into guidance for contention-heavy systems and for how the organisation decides.

1A Quick Recap of Lock-Based Concurrency

Classic databases ran strict two-phase locking. Every read took a shared lock and every write an exclusive lock, held until the end of the transaction, and a transaction that needed a conflicting lock waited. This is simple and gives serializable results with range locks, but it means a writer waits for every reader of a row, and a reader waits for every writer.

2Why the Ecosystem Moved

As systems grew, workloads became mixed: thousands of short write transactions alongside reports and dashboards reading large parts of the same tables. Under pure locking, a ten-minute report held shared locks on everything it read, blocking updates; or, to avoid that, it ran at a low isolation level and read inconsistent data. Lock escalation, where a database replaces many row locks with a table lock to save memory, made it worse. Teams spent effort on dirty reads, NOLOCK hints and night-time batch windows.

MVCC, multi-version concurrency control, keeps old versions of rows so that a reader sees a consistent snapshot without taking any locks. Readers never block writers and writers never block readers. Oracle used this approach early, PostgreSQL built on it, InnoDB adopted it, and SQL Server added snapshot-based options. The cost moved elsewhere: storing old versions in the table or in undo logs, and cleaning them up with VACUUM or purge, which brought new operational problems like bloat and long-transaction horizons.

What changed between the two models
AspectPure strict 2PLMVCC with write locks
Reader vs writerblock each othernever block each other
Writer vs writer, same rowwaitwait
Consistent long reportsblock writers or read dirtysnapshot, no blocking
Hidden costlock memory, escalation, deadlocksversion storage, vacuum, purge
Write skewprevented with range locksallowed unless SSI or locking reads

3What MVCC Moved Onto the Application

Under locking at SERIALIZABLE, a transaction that read a set of rows held locks on them, so another transaction could not change them and break a rule based on that read. Under snapshot-based MVCC, reads take no locks, so two transactions can each read the same rows, decide, and write different rows: write skew. Default levels like READ COMMITTED also allow lost updates in read-then-write code. Unless the team uses PostgreSQL's SSI, locking reads, or constraints, the burden of preventing these anomalies sits in application code, often written by people who do not know it is there.

4Locks Never Went Away

Every MVCC database still locks. Writes take exclusive row locks held until commit, so two writers of the same row still wait, and still deadlock. SELECT ... FOR UPDATE and FOR SHARE are explicit locks. PostgreSQL offers advisory locks on arbitrary keys. InnoDB adds gap and next-key locks to locking reads under REPEATABLE READ to stop phantoms. So teams must understand both models: MVCC to know what a read sees, and locking to know what a write waits for.

5Designing Contention-Heavy Systems Today

The deepest lesson of the history is that both models break down on the same thing: many transactions wanting the same data at the same moment. Locking makes them queue; MVCC makes them conflict and retry. Neither makes a hot row fast. So for contention-heavy systems the design goal is to avoid contention rather than manage it. A single hot counter, such as a stock count or a like count, can be split into N partial rows that are summed when read. A balance that every payment updates can become an append-only ledger of entries, with the balance derived, so writers insert instead of updating one row. Work for one key can be queued and processed in order by one consumer per key, so there is no concurrent writer at all. These single-writer designs remove the conflict instead of arbitrating it.

Step throughChoosing a design for a hot spot
  1. Is it a counter or total?
    YesSplit into partial rows or a ledgerNoGo on
  2. Can one owner process each key in order?
    YesQueue per key, single writerNoGo on
  3. Few writers, short transactions?
    YesConditional update or row lockNoSSI with retries, measure abort rate
  4. Record the decision and load test itrevisit when the workload changes

4 steps in order. Play them, or step through them one at a time.

6The Organisational Lesson

The industry needed decades to move from one concurrency model to another, because concurrency strategy is baked into schemas, code and operations. Inside a company it is the same at smaller scale: a choice like 'counters are single rows updated in place' or 'all services run READ COMMITTED' lasts for years. So I would treat it as an architecture decision. Write it down with the reasoning and the alternatives, test it under realistic concurrent load before launch rather than discovering it in production, and revisit it when the workload changes, for example when a feature becomes viral or a batch job becomes real time.

7Follow-up questions

Give an example where a single-writer design beats locking.

Seat allocation for a popular concert. With locking, thousands of requests per second for the same event queue on the event's row or seat rows, and latency grows with the queue. Instead, requests are written to a queue partitioned by event id, and one consumer per partition allocates seats in memory in arrival order and writes the result. There is no concurrent writer for an event, so no locks are contended and no retries happen; throughput is limited only by how fast one consumer can process requests, which is easily tens of thousands per second for simple allocation.

Is MVCC always better than locking?

No. For write-heavy workloads with few long reads, MVCC's version cleanup is pure overhead, and some lock-based engines do very well. MVCC wins on mixed read and write workloads.

Why do MVCC databases still need deadlock detection?

Because writes still take exclusive row locks held to commit, so two writers can wait on each other in a cycle exactly as under 2PL.

8Conclusion

In this answer, we saw that pure two-phase locking made readers and writers block each other, which hurt mixed workloads, and that MVCC removed that blocking in exchange for version storage and cleanup. MVCC also moved write skew and lost updates onto the application unless SSI, locking reads or constraints are used, and locks for writes, FOR UPDATE, advisory locks and next-key locks are still everywhere. For contention-heavy systems the lesson is to avoid contention with partitioned counters, ledgers, per-key queues and single writers, and to treat the strategy as a recorded and tested architecture decision.

What to say in the interviewAbout 80 seconds aloud

Open with

The move happened because strict two-phase locking makes readers and writers block each other. That was fine for small transactional systems, but once workloads mixed short writes with long reports, a report's shared locks blocked updates, or people used dirty reads to avoid that.

Then, if they want more

MVCC fixed it by keeping old row versions so readers see a snapshot without locks. The cost moved into version storage and cleanup, VACUUM in PostgreSQL and purge in InnoDB.

MVCC also moved some anomalies onto the application: with snapshot reads there are no read locks, so write skew and lost updates are possible unless you use SSI, locking reads or constraints. And locks never left. Writes still take row locks, we still use select for update, advisory locks and InnoDB's next-key locks, so teams need to understand both models.

The lesson I take for contention-heavy systems is that neither model makes a hot row fast. Locking makes requests queue, and MVCC makes them conflict and retry. So I'd design contention away: split hot counters into partial rows, use append-only ledgers instead of updating one balance, queue work per key with a single writer.

And organisationally, I'd treat the concurrency strategy as an architecture decision, written down, load tested before launch, and revisited when the workload changes.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Lock-based concurrency control dominated databases for decades and was then largely...": https://scrivio-interview-library.netlify.app/databases/acid-and-isolation/a7196442ac/