Scrivio Interview library
LeadershipPrincipal6 min read · updated 12 November 2026

Declarative transactions with @Transactional made it easy for developers to ignore transaction boundaries. Looking at distributed systems built over 15 years, how should an organisation think about transactional consistency as systems spread across services?

Within one service and its own database, local ACID transactions remain the simplest and strongest tool, and we should keep using them. Across services, distributed transactions with XA and two-phase commit were largely abandoned because they hurt availability and are hard to operate, so consistency comes instead from sagas, the outbox pattern, idempotent operations and reconciliation. The most important long-term decision is where we draw service boundaries: data that must change atomically should stay in one service, and engineers should be trained to make boundaries explicit rather than trusting an annotation.

Why this question is asked

@Transactional made transaction handling so easy inside a monolith that many engineers never had to think about where a unit of work starts and ends. When those systems were split into services, the annotation kept working inside each service, but it silently stopped covering the business operation as a whole. Interviewers ask senior candidates this question to hear how they think about consistency as an architectural property that an organisation must manage over many years, not as a library feature. In this answer, we will look at what local transactions still give us, why two-phase commit faded, which patterns replaced it, how boundaries decide the cost, and how to build the skills to make it all explicit.

1What Local Transactions Still Give Us

A local ACID transaction (atomic, consistent, isolated, durable) on one database is still the best consistency tool we have. If an order and its lines are in the same database, one commit makes them appear together, constraints check every row, and a failure leaves no trace. It costs a few milliseconds and needs no extra infrastructure.

So the first principle for an organisation is not 'avoid transactions' but 'use them fully where they apply'. Inside a service's own data, every use case should be one well-defined transaction. Many of the hardest consistency problems I have seen came from services that split work the database could have done atomically into several steps.

2Why Two-Phase Commit Faded

Two-phase commit (2PC), standardised for Java through XA and JTA, coordinates a commit across several resources. A coordinator first asks every participant to prepare, which means promising it can commit and holding its locks, and only when all say yes tells them to commit.

It works, but at a price that grew with distributed systems. While a participant waits for the coordinator's decision, its locks stay held; if the coordinator crashes at that moment, the participant is 'in doubt' and blocks until someone recovers it. Every participant must be available for any transaction to complete, so the availability of the whole is lower than that of each part. Message brokers, HTTP APIs and most cloud data services do not support XA at all. So, outside a few specialised cases such as a database and a message queue on the same platform, most organisations stopped using it.

3What Replaced It: Sagas, Outboxes, Idempotency, Reconciliation

Without a shared commit, we accept that a business operation spanning services passes through intermediate states, and we design so that it always reaches a correct final state. Four patterns do most of the work, and they are usually combined.

Consistency tools by scope
ToolScopeMain cost
Local ACID transactionOne service, one databaseAlmost none
XA / two-phase commitSeveral resources at onceBlocking, lower availability, little support
Saga with compensationsBusiness process across servicesDesign of every undo step
OutboxData change plus event, one serviceRelay process, at-least-once delivery
Idempotency keysEvery step that may be retriedStorage of processed keys
ReconciliationAnything that driftedDetection is delayed, not prevented

A saga breaks the operation into local transactions, one per service, each with a compensating action that undoes its effect, such as refunding a payment if shipping fails. The outbox pattern makes 'change my data and announce it' atomic within one service by writing the event to a table in the same transaction and publishing it afterwards. Idempotency makes every step safe to repeat, which is essential because messages are delivered at least once. Reconciliation is the safety net: a periodic job compares states across systems and fixes or reports differences that slipped through.

4Service Boundaries Decide the Long-Term Cost

The patterns above are not free. A saga for a process that a single transaction could have handled might mean five new message types, five compensations and a reconciliation job, plus the operational work of watching all of them. Over fifteen years, I have seen that cost dominate the budget of teams whose services were split along technical or organisational lines instead of along consistency needs.

So the most important design rule is this: data that must change atomically belongs in the same service. If 'an account's balance must equal the sum of its entries' is a hard rule, the balance and the entries live together. If inventory and orders can tolerate a few seconds of disagreement with a compensating step, they can be separate. When I review a proposal to split a service, the first question I ask is which invariants would cross the new boundary and what each one would cost to keep.

Step throughDeciding how to keep a rule consistent
  1. Is the data owned by one service?
    YesUse a local transactionNoGo on
  2. Must the rule hold at every instant?
    YesMove the data into one serviceNoGo on
  3. Can a step be undone if a later step fails?
    YesSaga with compensationsNoReserve or confirm in a different order
  4. Publish changes with an outbox; make steps idempotent
  5. Reconcile on a schedule and alert on drift

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

5Making Boundaries Explicit, Not Annotated

The cultural lesson is that @Transactional taught engineers to think of consistency as something a framework handles. Across services, nothing handles it unless we design it. I would invest in three things. Training, so every engineer can explain isolation levels, the outbox pattern and idempotency with an example from our own systems. Design reviews in which every cross-service operation must name its intermediate states, compensations and how we detect drift. And shared libraries for the outbox and idempotency key storage, so teams do not reinvent them badly.

I would also measure: how many orders sit in an intermediate state for longer than expected, how many reconciliation corrections happen per week. Those numbers turn consistency from an assumption into something the organisation can see and improve.

6Follow-up questions

Is there any place where you would still use XA?

Rarely. If a legacy system must update a database and a JMS queue on the same application server, and both support XA well, it can be acceptable. For new designs I would use an outbox instead, because it needs only the local database transaction.

How do you explain eventual consistency to product managers?

In business terms: the order is accepted immediately, and the confirmation arrives a moment later, just as a card payment shows as pending. We agree on the maximum acceptable delay and what the user sees in between, and we make the rare failure cases visible rather than silent.

What signals tell you a service boundary is wrong?

Frequent sagas between the same two services, compensations that fire often, reconciliation jobs that keep finding drift, and features that always need changes in both services. Those suggest the two pieces of data belong together.

7Conclusion

In this answer, we saw that local ACID transactions remain the right tool for a service's own data, that XA and two-phase commit were mostly abandoned because of blocking, availability and lack of support, and that across services consistency comes from sagas, outboxes, idempotency and reconciliation. The largest long-term cost is set by where service boundaries fall, so data that must change atomically should stay together, and engineers should be trained to design boundaries explicitly instead of relying on an annotation.

What to say in the interviewAbout 90 seconds aloud

Open with

I'd frame it in three parts. First, inside a service, local ACID transactions are still the simplest and strongest tool, and we should use them fully: each use case one transaction on the service's own database.

Then, if they want more

A lot of pain comes from splitting work into steps that one commit could have done. Second, across services, we largely gave up on distributed transactions. XA and two-phase commit hold locks while waiting for the coordinator, they block if it crashes, they make availability depend on every participant, and most brokers and HTTP APIs don't support them anyway.

So consistency across services comes from sagas with compensating actions, the outbox pattern to make a data change and its event atomic, idempotent steps because delivery is at least once, and reconciliation jobs as the safety net. Third, and most important for the long term, service boundaries should follow consistency needs.

If two pieces of data must change together at every instant, splitting them buys you sagas and reconciliation forever, so I'd keep them in one service.

Culturally, I'd train engineers to name the intermediate states, compensations and drift detection for every cross-service operation in design reviews, give them shared outbox and idempotency libraries, and track how long things sit in intermediate states, so consistency is designed rather than assumed from an annotation.

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 "Declarative transactions with @Transactional made it easy for developers to ignore...": https://scrivio-interview-library.netlify.app/databases/transactions/7bb78be04f/