Scrivio Interview library
LeadershipPrincipal6 min read · updated 12 November 2026

Twenty years ago most enterprise applications relied on database locks and READ COMMITTED; today many teams use ORMs, microservices and distributed databases. How should a company's engineering standards on transaction isolation change, and how do you make sure the standard is followed?

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 standard should change in two directions at once. Inside one database, stronger isolation has become cheap enough that the default should be the strongest level the workload tolerates, with documented exceptions; across services, where no database isolation applies at all, the standard should require sagas, the outbox pattern and idempotency instead of pretending to have transactions. We make sure it is followed by turning it into shared libraries, schema linting and test templates, by tracking incidents and abort rates, and by teaching people why it matters.

Why this question is asked

Twenty years ago a typical enterprise application ran on one big database, and the database's locks were the concurrency strategy, whether anyone said so or not. Today one business operation may cross five services, an ORM writes most of the SQL, and some data lives in a distributed database. A standard written for the old world either does nothing or does harm in the new one. Interviewers ask this of senior leaders because it tests whether they can update a technical standard and also get hundreds of engineers to follow it. In this answer, we will look at what changed, what the new standard says, how to make it executable, how to track it, and why education is part of it.

1What Changed in Twenty Years

Two shifts pull in opposite directions. The first is that invariants, the rules that must always hold, now often span services. An order service, a payment service and an inventory service each have their own database, so 'do not ship an order that was not paid' crosses three databases, and no isolation level of any one of them covers it. Engineers who learned that @Transactional makes things safe can be badly misled here.

The second is that inside a single database, strong isolation has become far cheaper. PostgreSQL's Serializable Snapshot Isolation gives true serializability without making readers wait, and distributed SQL databases offer serializable as their default. ORMs, meanwhile, hide the SQL, so developers often do not see the read-then-write patterns that cause anomalies. The old standard, READ COMMITTED plus careful locking, relied on people seeing exactly what they now cannot see.

2The Standard Inside One Database

Within one database, the standard is to use the strongest isolation level the workload tolerates, by default SERIALIZABLE on PostgreSQL for data with invariants, with any lower level written down as an exception that names the protection used instead, such as a constraint or a conditional update. Constraints remain the first line of defence because they hold for every writer. Every service also states, in its design document, which invariants it protects and how.

3The Standard Across Services

Across services, the standard says plainly that there is no transaction, and asks for patterns designed for that. A multi-step business process is a saga: a sequence of local transactions, each with a compensating action if a later step fails, for example refund the payment if the stock reservation fails. Messages are published with the outbox pattern, written to an outbox table in the same local transaction as the business change and relayed afterwards, so a change and its event cannot disagree. Every consumer and every API that can be retried is idempotent, using an idempotency key, so duplicates from retries do no harm. Distributed two-phase commit is discouraged except where a team proves it is needed.

Step throughWhere each kind of guarantee lives
  1. Across servicessagas, compensations, outbox, idempotency keys
  2. Service boundaryAPI contracts, retries with idempotency
  3. Inside one service's databaseSERIALIZABLE by default, documented exceptions
  4. Schemaunique, exclusion and foreign key constraints

4 layers, from the top down. Step through them one at a time.

Isolation levels only reach as far as one database.

4Making the Standard Executable

A standard that lives only in a wiki is followed by the people who already agree with it. So the platform turns it into code that teams get for free. A shared transaction library sets the isolation level, retries 40001 and 40P01 with backoff, and records metrics. A saga and outbox library provides the outbox table, the relay and idempotent consumer helpers. A schema linter in the migration pipeline flags tables with obvious missing constraints, such as an is_primary flag with no partial unique index. And concurrency test templates, two transactions synchronised with a latch against a real database in Testcontainers, let teams prove their invariants hold under interleaving.

5Tracking Compliance and Outcomes

We track two kinds of numbers. Compliance numbers say whether teams use the paved path: the share of services on the shared transaction library, the number of documented isolation exceptions, and services with concurrency tests for their key invariants. Outcome numbers say whether it works: incidents whose root cause was an anomaly or a lost message, retry and abort rates per service, and findings from reconciliation jobs that compare invariants across services, such as paid orders without a shipment. These are reviewed in the architecture forum each quarter, and a service with high findings gets help, not blame.

Step throughHow the standard is kept alive
  1. Publish standard and paved pathlibraries, linter, test templates
  2. Teams adopt by defaultexceptions documented in design docs
  3. Measureincidents, abort rates, reconciliation findings
  4. Quarterly architecture reviewhelp the outliers, update the standard
  5. Standard still fits the workloads?
    YesKeep goingNoRevise and announce

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

6Why Education Is Part of the Standard

Isolation bugs almost never appear in tests, because tests run one request at a time, and they appear in production only under load, often months after the code shipped. That means engineers rarely learn from their own mistakes in time. So we invest in teaching: a short internal course built on our own incident reviews, a reference page per database product on what its isolation levels really do, and pairing for teams adopting sagas for the first time. The goal is that engineers understand why the paved path exists, so they recognise the cases it does not cover.

7Follow-up questions

How would you handle a team that refuses for performance reasons?

I would take the concern seriously and ask for data. We would load test their hottest path at SERIALIZABLE with the shared retry library and measure abort rate and p99 latency against their budget. If it really does not fit, the standard already allows an exception: they document the lower isolation level and the specific protection that replaces it, such as conditional updates or a lock row, plus a concurrency test that proves the invariant holds. What I would not accept is a lower level with no stated protection, because that just moves the cost into future incidents.

Why discourage distributed two-phase commit?

It couples the availability of every participant: one slow or failed service blocks the others while locks are held. Sagas accept temporary inconsistency in exchange for independence, which suits most business processes.

How do you know the standard is working?

When anomaly-caused incidents and reconciliation findings fall over several quarters while delivery speed holds steady. If incidents fall but teams slow down a lot, the paved path is too heavy and needs work.

8Conclusion

In this answer, we saw that invariants now often span services, where no database isolation applies, while strong isolation inside one database has become cheap. The standard therefore defaults to the strongest tolerable level inside a database, with documented exceptions, and requires sagas, the outbox pattern and idempotency across services. It is made executable with shared libraries, schema linting and concurrency test templates, tracked through incidents, abort rates and reconciliation findings in architecture reviews, and supported by education, because these bugs rarely appear in tests.

What to say in the interviewAbout 80 seconds aloud

Open with

I'd start by explaining the shift. Twenty years ago one database held the invariants, and its locks at READ COMMITTED were the strategy. Now an invariant like don't ship unpaid orders spans three services, and no isolation level covers that, while inside one database strong isolation got cheap thanks to SSI in PostgreSQL and serializable defaults in distributed SQL.

Then, if they want more

So the standard has two parts. Inside one database, default to the strongest level the workload tolerates, usually SERIALIZABLE for data with invariants, with constraints first and any lower level documented with the protection that replaces it. Across services, don't pretend there's a transaction: use sagas with compensations, the outbox pattern for events, and idempotency keys for anything retried.

To make it followed, I'd make it executable: a shared transaction library with retries and metrics, an outbox library, schema linting in the migration pipeline, and concurrency test templates with Testcontainers. Then I'd track compliance and outcomes, like adoption of the library, incidents caused by anomalies, abort rates and reconciliation findings, and review them quarterly in the architecture forum.

And I'd invest in education built on our own incidents, because isolation bugs rarely show up in tests and only appear under production load.

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 "Twenty years ago most enterprise applications relied on database locks and READ...": https://scrivio-interview-library.netlify.app/databases/acid-and-isolation/89a5a9bd40/