Learning roadmap
Learn each topic from scratch, then practice the interview questions on it — in order.
1
1. Learn
What Is a Transaction?AtomicityConsistencyIsolation & AnomaliesDurabilitySQL Transaction ControlLocking, MVCC & Deadlocks@Transactional FundamentalsPropagation & Isolation in SpringTransaction Manager InternalsProgrammatic, Reactive & Nested TransactionsPersistence Context & Dirty CheckingEntity Lifecycle, Caching & Transaction BoundariesMongoDB TransactionsWhy Local Transactions FailTwo-Phase Commit (2PC)Saga PatternOutbox, Inbox & CDCKafka Transactions & Exactly-Once SemanticsSystem Design with TransactionsProduction EngineeringCapstone — A Fault-Tolerant Order-Payment System
2. Practice interview questions
Is a single INSERT statement a transaction?In your own words, what is a database transaction?Give a real-world (non-technical) example of a transaction.Why isn't "just do the operations one after another in application code" sufficient?Can a transaction consist of read-only operations?When does the "single transaction" mental model stop being applicable at all?What are the only two possible endings of a transaction?What's the shared shape across the ATM, flight, and shopping examples?What does atomicity guarantee?How does a database implement atomicity internally?If a transaction sends an email via a third-party API and then rolls back, is the email un-sent?How would you safely combine "update the database" and "call an external API" as one logical, all-or-nothing unit?What's the difference between ACID consistency and CAP consistency?Does ACID consistency have its own dedicated internal mechanism, like atomicity has undo logs?Can a database with perfect atomicity and isolation still be "inconsistent"?What does isolation control?Order the four isolation levels from weakest to strongest.Why does PostgreSQL's Repeatable Read prevent phantom reads, when the SQL standard doesn't require it to?How would you decide isolation level on a per-operation, not per-application, basis?What's the difference between a dirty read and a non-repeatable read?Which isolation level is the default in PostgreSQL?Which isolation level is the default in MySQL/InnoDB?Which anomaly does Serializable prevent that Repeatable Read (per the SQL standard) does not?What does durability guarantee?Why does the database write to a separate log before updating the real data files?What's the practical risk of setting synchronous_commit = off on a payments database?What does autocommit mode mean?What's the difference between ROLLBACK and ROLLBACK TO SAVEPOINT?Does standard SQL support true nested transactions?What's the core difference between optimistic and pessimistic locking?Why doesn't a long-running SELECT block a concurrent UPDATE under PostgreSQL's MVCC?What's the actual root cause of most production deadlocks, and what's the real fix (not just a mitigation)?When would you choose pessimistic locking over optimistic, at scale?Does @Transactional roll back on every exception by default?Does readOnly = true prevent a write statement from executing?Why is this default rollback behavior considered a design trap in real codebases?What's the default propagation type in Spring?What's the real difference between REQUIRES_NEW and NESTED?Why doesn't setting isolation = SERIALIZABLE on a REQUIRED method that joins an existing transaction do anything?When would REQUIRES_NEW create a deadlock risk against its own caller?How does Spring actually implement @Transactional under the hood?Why does calling this.someTransactionalMethod() from within the same class not create a transaction?What are the three ways to fix the self-invocation problem, and which is generally preferred?Why would you use afterCommit() instead of just putting an email send at the end of a @Transactional method?When would you use TransactionTemplate instead of @Transactional?Why does classic @Transactional not work correctly in a reactive application?What's the real danger of calling a blocking JDBC repository from a reactive WebFlux service?Why does modifying a loaded entity's field update the database without an explicit save() call?What's the difference between flush and commit?Why does modifying a detached entity silently do nothing?Why might you deliberately set FlushMode.COMMIT instead of the default AUTO?What are the four entity states in JPA?Is the second-level cache enabled by default?Why does accessing a lazy relationship after the transaction ends throw an exception instead of returning stale data?Why is "Open Session in View" generally considered an anti-pattern despite solving the LazyInitializationException problem?Has MongoDB always supported atomicity, even before "transactions" existed as a named feature?Why can't a standalone (non-replica-set) MongoDB instance run a multi-document transaction?What's MongoDB's own recommended default strategy regarding multi-document transactions?How does Spring's transaction abstraction let you swap SQL for MongoDB with minimal code change?Why can't @Transactional protect a call to a different microservice's REST API?What is the "dual-write problem," specifically?Is this fundamentally a Spring/framework limitation, or a deeper constraint?What are the two phases in Two-Phase Commit?What happens to a participant that voted YES if the coordinator crashes before phase 2?Why is 2PC generally avoided in modern microservices architectures?In a system design interview, when would choosing 2PC over Saga actually be the right call?What replaces atomicity in a Saga, since there's no real cross-service ROLLBACK?What's the core structural difference between choreography and orchestration?Why must every saga step be idempotent?How would you design the ordering of steps in a saga with one genuinely irreversible action (like sending a physical package)?What problem does the Outbox Pattern solve?Why is CDC (via Debezium) preferred over a hand-written polling relay?How does the Inbox Pattern mirror the Outbox Pattern's core insight?Why must the outbox table live in the exact same database as the business tables it's paired with?What does Kafka guarantee by default: at-most-once, at-least-once, or exactly-once?What two separate mechanisms combine to give Kafka exactly-once semantics?Does read_committed alone give you exactly-once semantics?Does Kafka's exactly-once semantics extend to a write against an external database like Postgres?Design the money-movement part of a UPI-like system. What pattern do you use, and why not a single distributed transaction?How do you prevent overselling the last unit of a flash-sale item?Why is 2PC generally the wrong answer in a ride-sharing or e-commerce system design interview?What does "idle in transaction" mean, and why is it dangerous?How would you debug a saga that appears stuck, spanning four microservices?What metric would give you the earliest warning that your Outbox relay is failing, before any consumer notices missing events?1. "What is a transaction? Give a real-world example." (30 seconds)2. "Explain ACID. Which property has no dedicated internal mechanism of its own?" (2 minutes)3. "Why does self-calling a @Transactional method from within the same class not work?" (2 minutes)4. "Design the payment flow for a food delivery app spanning Order, Payment, and Restaurant services. What pattern, and why not a distributed transaction?" (4 minutes)5. "How do you guarantee the 'order placed' event is never lost, even if Kafka is briefly down?" (90 seconds)
2
3