Quick revision
The short answer
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.
What to remember
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.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
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.
| Aspect | Pure strict 2PL | MVCC with write locks |
|---|---|---|
| Reader vs writer | block each other | never block each other |
| Writer vs writer, same row | wait | wait |
| Consistent long reports | block writers or read dirty | snapshot, no blocking |
| Hidden cost | lock memory, escalation, deadlocks | version storage, vacuum, purge |
| Write skew | prevented with range locks | allowed 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.
- Is it a counter or total?YesSplit into partial rows or a ledgerNoGo on
- Can one owner process each key in order?YesQueue per key, single writerNoGo on
- Few writers, short transactions?YesConditional update or row lockNoSSI with retries, measure abort rate
- 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.
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.
- Official documentation
- PostgreSQL documentation, MySQL reference manual
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/