PrepStack › Databases › Transactions & Isolation
Transactions & Isolation interview cheat sheet
ACID, anomalies, isolation levels, MVCC, locking, deadlocks and distributed transactions
Transaction questions separate people who have only written CRUD from people who have debugged production data bugs. Interviewers check that you can name each anomaly, say which isolation level stops it in Postgres vs MySQL, explain MVCC and locking underneath, and pick a safe pattern for money, stock and seat booking. SQLite snippets are runnable; concurrency anomalies are shown as two-session timelines because they need two real connections. Read the 15-minute list, then quiz yourself on the scenarios.
15-minute revision
- A transaction is a group of statements that succeed or fail as one unit:
BEGIN…COMMITkeeps all,ROLLBACKundoes all. - ACID: Atomicity (all or nothing, via undo/rollback), Consistency (constraints hold), Isolation (concurrent txs do not see each other's mess), Durability (committed = survives a crash, via the WAL/redo log + fsync).
- Write-ahead logging: the log record must hit disk before the data page does, and
COMMITwaits for the log flush. Crash recovery replays (redo) committed work and undoes uncommitted work. - Most drivers and DBs run in autocommit by default: each statement is its own transaction until you
BEGIN. MySQL and Oracle DDL causes an implicit commit; Postgres DDL is transactional. SAVEPOINT s/ROLLBACK TO s/RELEASE sundo part of a transaction without aborting it. Nothing is durable until the outerCOMMIT.- Anomalies: dirty read (see uncommitted), non-repeatable read (row changed between reads), phantom (new rows match a re-run query), lost update, read skew, write skew.
- ANSI levels: Read Uncommitted < Read Committed < Repeatable Read < Serializable. Each level forbids more anomalies; only Serializable forbids all of them.
- Defaults: Postgres, SQL Server, Oracle = Read Committed; MySQL InnoDB = Repeatable Read. Postgres treats Read Uncommitted as Read Committed; Oracle offers only Read Committed and Serializable.
- Snapshot isolation (Postgres RR, Oracle 'Serializable', SQL Server SNAPSHOT) reads one consistent snapshot and stops lost updates with first-updater-wins, but still allows write skew.
- SSI (Postgres SERIALIZABLE) is snapshot isolation plus tracking of read/write dependencies; it aborts a tx with SQLSTATE
40001when a cycle could form. Apps must retry. - MVCC: writers create new row versions; readers pick the version visible to their snapshot. Readers never block writers and writers never block readers. Old versions are cleaned by VACUUM (Postgres) or purge (InnoDB).
- Locks: S (shared) is compatible with S; X (exclusive) conflicts with everything. Intention locks (IS/IX) on the table say 'I hold row locks below'. InnoDB adds gap and next-key locks to stop phantoms.
SELECT … FOR UPDATElocks the rows you read;NOWAITerrors instead of waiting;SKIP LOCKEDskips locked rows (job queues).- Optimistic = no lock, check a
versioncolumn on update and retry on conflict. Pessimistic = lock first (FOR UPDATE). Use optimistic when conflicts are rare. - Deadlock = cycle of lock waits. DBs detect it and kill one victim. Prevent by locking rows in a consistent order, keeping txs short, and retrying the victim.
- Across services avoid 2PC where you can; use a saga (local txs + compensations) and the transactional outbox to publish events reliably.
Transaction basics & ACID
What a transaction is
A transaction is a unit of work that either fully happens or does not happen at all, and is isolated from other concurrent work.
- Start with
BEGIN(orSTART TRANSACTION), end withCOMMITto keep the changes orROLLBACKto discard them. - Inside the transaction your own changes are visible to you; other sessions see them only after
COMMIT(at Read Committed and above). - The classic example is a bank transfer: debit one account and credit another. Doing only one half would create or destroy money.
- A transaction is also the unit of locking and visibility: locks taken inside it are usually held until it ends.
- Keep transactions short. Never wait for user input, HTTP calls or long computations while a transaction is open.
Interview questions
- What is a database transaction?
- What happens to an open transaction if the client disconnects?
- Why should transactions be short?
ACID properties in depth
Atomicity, Consistency, Isolation and Durability are the four guarantees a transactional database gives you.
- Atomicity: all or nothing. If anything fails or you call
ROLLBACK, the database undoes every change of the transaction. - Consistency: a transaction moves the database from one valid state to another. The DB enforces declared rules (PK, FK, UNIQUE, CHECK, NOT NULL); business rules are the app's job.
- Isolation: concurrent transactions behave as if they ran alone, to the degree set by the isolation level. Full isolation = Serializable.
- Durability: once
COMMITreturns, the change survives crashes and power loss, because the log was flushed (fsync) to stable storage. - The 'C' is the odd one out: A, I and D are mechanisms the DB provides; C is the goal the app reaches by using them plus constraints.
Interview questions
- Explain ACID.
- Which ACID property is the application responsible for?
- Is ACID consistency the same as consistency in CAP?
How atomicity & durability work: WAL, redo, undo
Changes are first written to an append-only log that is flushed on commit; after a crash the DB redoes committed work and undoes the rest.
- Write-ahead logging (WAL): a log record describing a change must reach disk before the changed data page does. Postgres calls it the WAL; InnoDB calls it the redo log.
- On
COMMITthe DB only has to fsync the log (sequential, fast), not the scattered data pages. Pages are written later by checkpoints / background flushing. - Redo information replays committed changes that had not reached the data files when the crash happened.
- Undo information reverses changes of transactions that never committed. InnoDB keeps it in undo logs (also used for MVCC). Postgres has no undo log: old versions stay in the table and an aborted txid is simply marked aborted in the commit log (
pg_xact). - Group commit batches several transactions' log flushes into one fsync, which is how busy systems get high commit throughput.
- Tuning knobs trade durability for speed: Postgres
synchronous_commit = off, MySQLinnodb_flush_log_at_trx_commit = 0/2. A crash can then lose the last moments of commits (but not corrupt data).
Interview questions
- How does a database guarantee durability without writing every data page on commit?
- What is the difference between redo and undo logs?
- What is a checkpoint?
- What does
innodb_flush_log_at_trx_commit = 2change?
Autocommit & implicit transactions
Without an explicit BEGIN, most databases wrap each statement in its own transaction and commit it immediately.
- In autocommit mode each statement is atomic on its own: a failing multi-row
UPDATEchanges no rows, but two statements are not atomic together. BEGIN/START TRANSACTIONturns autocommit off until the nextCOMMITorROLLBACK.- Defaults differ by client: JDBC connections start with
autoCommit = true; Python DB-API drivers (psycopg, sqlite3 legacy mode) implicitly open a transaction and expect you to callcommit(). - Implicit commit: in MySQL and Oracle, DDL such as
CREATE/ALTER TABLEcommits the current transaction first. Postgres and SQL Server DDL is transactional, so a failed migration can roll back cleanly. - In Postgres, after any error inside a transaction block the tx is aborted: every later statement fails with 'current transaction is aborted' until
ROLLBACK(orROLLBACK TOa savepoint).
Interview questions
- What is autocommit?
- Why are bulk inserts faster inside one transaction?
- Can you roll back a
CREATE TABLE?
Savepoints & partial rollback
A savepoint is a named mark inside a transaction you can roll back to without abandoning the whole transaction.
SAVEPOINT namesets a mark;ROLLBACK TO nameundoes everything after it but keeps the transaction open;RELEASE nameremoves the mark.- Savepoints nest. Rolling back to an outer savepoint also undoes inner savepoints, even released ones.
- Nothing is durable until the outermost COMMIT. A released savepoint is merged into its parent, not committed.
- Use them for optional steps, for 'try insert, on duplicate do something else' inside a larger tx, and to recover from errors in Postgres's aborted-transaction state.
- Frameworks use them for nested transactions: Spring's
Propagation.NESTEDand Django's nestedatomic()blocks create savepoints.
Interview questions
- What is a savepoint and when would you use one?
- Does
RELEASE SAVEPOINTcommit the work? - In Postgres, a statement fails inside a transaction. What happens and how do you recover?
Anomalies & isolation levels
Read phenomena: dirty, non-repeatable, phantom
The three ANSI anomalies describe what a transaction can wrongly see because of another concurrent transaction.
- Dirty read: T1 reads data that T2 wrote but has not committed. If T2 rolls back, T1 used data that never existed.
- Non-repeatable read: T1 reads a row twice and gets different values because T2 updated (or deleted) and committed it in between.
- Phantom read: T1 re-runs a query with a
WHEREcondition and gets a different set of rows because T2 inserted or deleted matching rows. - Non-repeatable is about one existing row changing; phantom is about the result set changing (new or vanished rows matching a predicate).
- Stopping phantoms with locks needs predicate or range locks (e.g. InnoDB next-key locks), because you cannot lock a row that does not exist yet. MVCC snapshots stop phantoms for plain reads.
Interview questions
- What is a dirty read?
- Difference between a non-repeatable read and a phantom read?
- Why can't ordinary row locks prevent phantoms?
Lost update, read skew & write skew
Beyond the ANSI three, real bugs come from lost updates, read skew and write skew, which some 'strong' levels still allow.
- Lost update: two txs read the same value, both compute a new value from it and write back. The second write overwrites the first. Classic read-modify-write bug (counters, stock, balances).
- Read skew: T1 reads X, then T2 updates X and Y and commits, then T1 reads Y. T1 sees a mix of old and new state (e.g. a transfer where money looks missing). Snapshot reads prevent it.
- Write skew: two txs read an overlapping set, each checks a rule, then each updates a different row. No row is written twice, so no write conflict, but together they break the rule.
- Write skew is the anomaly snapshot isolation allows; only true Serializable (SSI, 2PL) or explicit locking (
FOR UPDATEon the rows you read, or a constraint) stops it. - Fixes for lost update: an atomic update (
SET qty = qty - 1),SELECT … FOR UPDATE, optimistic version check, or Repeatable Read in Postgres (which aborts the second writer).
Interview questions
- What is a lost update and how do you prevent it?
- What is write skew? Give an example.
- What is read skew?
- Does Repeatable Read prevent lost updates?
The four isolation levels
Isolation levels trade correctness for concurrency: each higher level forbids more anomalies but costs more blocking or more aborts.
- Read Uncommitted: may see uncommitted data. Rarely useful; sometimes used for rough monitoring queries.
- Read Committed: each statement sees only committed data. Two statements in the same tx can see different data.
- Repeatable Read: rows you have read will not change under you. In MVCC engines this means one snapshot for the whole transaction.
- Serializable: the result is the same as some one-at-a-time order of the transactions. Implemented by strict 2PL with range locks, or by SSI.
- Set it per transaction:
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE(before the first query), or per session/server defaults.
Interview questions
- List the isolation levels and what each prevents.
- Difference between Read Committed and Repeatable Read in an MVCC database?
- Why not always use Serializable?
Default levels: Postgres vs MySQL vs SQL Server vs Oracle
Same level names mean different things in different engines, and the defaults differ.
- PostgreSQL: default Read Committed. Read Uncommitted behaves as Read Committed. Repeatable Read is snapshot isolation (no phantoms). Serializable is SSI.
- MySQL InnoDB: default Repeatable Read. Plain
SELECTs use a snapshot from the first read; locking reads andUPDATE/DELETEread the latest committed row and use next-key locks. Serializable turns plainSELECTs intoFOR SHAREreads when autocommit is off. - SQL Server: default Read Committed implemented with shared locks (readers block on writers) unless
READ_COMMITTED_SNAPSHOTis on (on by default in Azure SQL Database). SeparateSNAPSHOTlevel needsALLOW_SNAPSHOT_ISOLATION. - Oracle: default Read Committed with statement-level read consistency from undo. Its
SERIALIZABLEis really snapshot isolation (fails with ORA-08177); no Read Uncommitted or Repeatable Read. - Many apps moving from MySQL to Postgres silently drop from Repeatable Read to Read Committed. Check assumptions when migrating.
Interview questions
- What is the default isolation level in MySQL and in PostgreSQL?
- How does MySQL InnoDB's Repeatable Read avoid phantoms?
- What is RCSI in SQL Server?
Snapshot isolation & Serializable Snapshot Isolation (SSI)
Snapshot isolation gives each tx a frozen view and blocks concurrent writes to the same row; SSI adds dependency tracking to also catch write skew.
- Snapshot isolation (SI): all reads see the database as of the transaction's start. Writes conflict only if two txs write the same row: first updater (or committer) wins, the other aborts.
- SI prevents dirty reads, non-repeatable reads, phantoms (for reads), read skew and lost updates. It allows write skew because disjoint writes never conflict.
- SSI (Postgres Serializable since 9.1) runs on SI, but also records SIREAD locks (what each tx read). These never block; they only detect rw-antidependencies.
- If two consecutive rw-dependencies form a 'dangerous structure' (T1 →rw T2 →rw T3), Postgres aborts one tx with
could not serialize access(SQLSTATE40001). - SSI is optimistic: no extra blocking, but false positives happen. Keep txs short, mark read-only txs
READ ONLY(andDEFERRABLEfor long reports), and retry on 40001.
Interview questions
- What is snapshot isolation?
- Why is snapshot isolation not serializable?
- How does PostgreSQL's SSI work?
- What should an application do when it gets SQLSTATE 40001?
Concurrency control: MVCC & locking
MVCC: versions & visibility
Multi-version concurrency control keeps several versions of a row so each transaction can read the version that matches its snapshot.
- An
UPDATEdoes not overwrite in place; it creates a new version and marks the old one as superseded.DELETEjust marks the version as ended. - Postgres stores all versions in the table heap. Each tuple has
xmin(creating txid) andxmax(deleting/locking txid). A snapshot = (xmin, xmax, list of in-progress txids). - InnoDB/Oracle update in place and keep old versions in the undo log. Each row has a hidden
DB_TRX_IDand roll pointer; a read view walks back the undo chain to the visible version. - Visibility rule (simplified): a version is visible if its creator committed before my snapshot and its deleter did not.
- Payoff: readers never block writers and writers never block readers. Writers still block writers on the same row.
- Cost: old versions pile up. Postgres needs VACUUM (autovacuum) to reclaim dead tuples and to freeze old txids (32-bit txid wraparound); InnoDB's purge thread trims undo.
Interview questions
- What is MVCC and why is it used?
- How does Postgres decide if a row version is visible?
- How does InnoDB's MVCC differ from Postgres's?
- What is transaction ID wraparound in Postgres?
Locks: shared/exclusive, row/table, intention locks
Locks stop conflicting access: shared locks for reading, exclusive locks for writing, at row or table granularity, with intention locks linking the two.
- Shared (S) lock: many holders can read; blocks writers. Exclusive (X) lock: one holder; blocks both S and X.
- Row-level locks give high concurrency; table-level locks are cheap to manage but block more. Postgres and InnoDB lock rows; SQL Server can escalate many row/page locks to a table lock (around 5,000 locks by one statement on one object).
- Intention locks (IS, IX) are table-level flags meaning 'I hold or will take S/X locks on some rows'. They let a request for a full table lock check one entry instead of scanning every row lock.
- Writes (
UPDATE/DELETE) take row X locks automatically and hold them until the transaction ends. In MVCC engines plainSELECTtakes no row locks. - Postgres also has table lock modes for DDL and maintenance: e.g.
ALTER TABLEtakesACCESS EXCLUSIVE, which blocks even reads, and plain queries takeACCESS SHARE. - Lock waits can be bounded: Postgres
lock_timeout, MySQLinnodb_lock_wait_timeout(default 50 s), SQL ServerSET LOCK_TIMEOUT.
Interview questions
- Difference between shared and exclusive locks?
- What are intention locks and why do they exist?
- What is lock escalation?
InnoDB record, gap & next-key locks
InnoDB locks index records and the gaps between them so that locking reads at Repeatable Read cannot be invaded by phantom inserts.
- Record lock: locks one index record. InnoDB always locks index entries; without a usable index it scans and locks every row (and gap) it reads.
- Gap lock: locks the gap between two index records (or before the first / after the last). It only stops inserts into the gap; gap locks do not conflict with each other.
- Next-key lock = record lock + gap lock before that record. It is InnoDB's default for locking scans at Repeatable Read, and it prevents phantoms.
- Insert intention lock: a special gap lock taken by
INSERT; many inserts into the same gap at different positions do not block each other, but they wait for a gap/next-key lock. - A unique-index equality lookup that finds a row needs only a record lock. Ranges, non-unique indexes, and lookups that find nothing take gap or next-key locks.
- At Read Committed, gap locking is mostly disabled (kept for FK and duplicate-key checks), which reduces deadlocks but allows phantoms in locking reads.
Interview questions
- What is a gap lock in InnoDB?
- What is a next-key lock?
- Why do two 'SELECT … FOR UPDATE then INSERT' transactions deadlock in MySQL?
Two-phase locking (2PL)
2PL guarantees serializability by having each transaction acquire all its locks before releasing any.
- Growing phase: the transaction may acquire locks but not release any. Shrinking phase: it may release but not acquire.
- Any schedule that follows 2PL is conflict-serializable: the lock point of each tx gives a valid serial order.
- Strict 2PL holds all exclusive locks until commit/abort; strong strict (rigorous) 2PL holds all locks until the end. This avoids cascading aborts and is what real DBs do.
- To prevent phantoms 2PL needs predicate or index-range locks, not only row locks.
- Downsides: readers block writers and vice versa, and deadlocks are possible, so a deadlock detector is required.
- Do not confuse 2PL (locking inside one database) with 2PC (atomic commit across several databases).
Interview questions
- What is two-phase locking?
- Why do databases use strict 2PL instead of basic 2PL?
- Difference between 2PL and 2PC?
SELECT FOR UPDATE, NOWAIT & SKIP LOCKED
Locking reads take row locks at read time so nobody can change the rows before you write; NOWAIT and SKIP LOCKED control what happens on contention.
SELECT … FOR UPDATElocks the returned rows exclusively until the tx ends. OtherFOR UPDATE/UPDATE/DELETEon them wait; plain MVCC reads do not.FOR SHARE(MySQL 8 / Postgres; older MySQLLOCK IN SHARE MODE) takes a shared lock: others can read-lock but not modify.- Postgres adds weaker modes:
FOR NO KEY UPDATE(default for most UPDATEs) andFOR KEY SHARE(taken by FK checks), which reduce FK-related blocking. NOWAIT: fail immediately if a row is locked (good for 'someone else is editing this' UX).SKIP LOCKED: silently skip locked rows (good for work queues). Postgres 9.5+, MySQL 8.0+, Oracle; SQL Server usesWITH (UPDLOCK, READPAST).- Only lock what you need: add a selective
WHERE, an index, andLIMIT. Without an index InnoDB may lock a large range.
Interview questions
- What does
SELECT … FOR UPDATEdo? - Difference between
NOWAITandSKIP LOCKED? - How would you build a reliable job queue on a relational database?
Conflicts, deadlocks & long transactions
Optimistic vs pessimistic concurrency
Pessimistic control locks before acting; optimistic control acts without locks and checks for conflicts at write time.
- Pessimistic:
SELECT … FOR UPDATE(or a higher isolation level using locks). Safe and simple when conflicts are frequent, but blocks others and can deadlock. - Optimistic: add a
version(orupdated_at) column;UPDATE … SET …, version = version + 1 WHERE id = ? AND version = ?. If 0 rows changed, someone else won: reload and retry or show an error. - Optimistic works across long user think-time (edit form open for minutes) because no DB lock is held between read and write.
- ORMs support it: JPA/Hibernate
@VersionthrowsOptimisticLockException; Django needs a manual filtered update; EF Core uses concurrency tokens/rowversion. - Rule of thumb: low contention → optimistic; high contention or expensive retries → pessimistic.
Interview questions
- Difference between optimistic and pessimistic locking?
- How do you implement optimistic locking in SQL?
- Two users edit the same product page for five minutes. Which approach?
Deadlocks: detection, prevention & lock ordering
A deadlock is a cycle of transactions each waiting for a lock the next one holds; the DB breaks it by aborting a victim, and you prevent it mostly by lock ordering.
- Classic case: T1 locks row A then wants B; T2 locks B then wants A. Neither can proceed.
- Detection: the lock manager builds a wait-for graph and looks for cycles. InnoDB checks immediately on each wait (
innodb_deadlock_detect); Postgres checks after waitingdeadlock_timeout(default 1 s). - The victim is rolled back with an error: Postgres
deadlock detected(SQLSTATE40P01), MySQL error 1213, SQL Server error 1205. InnoDB prefers the transaction that changed the fewest rows. - Prevention: access rows/tables in a consistent order (e.g. by primary key), keep txs short, index your
WHEREcolumns so fewer rows are locked, and lock everything you need up front. - Retry the victim transaction; deadlocks are normal in busy OLTP systems, but frequent ones point to a design problem.
- Lock wait timeouts are different: no cycle, just waiting too long (MySQL error 1205 'Lock wait timeout exceeded').
Interview questions
- What is a deadlock and how does a database handle it?
- How do you prevent deadlocks?
- Difference between a deadlock and a lock wait timeout?
- Why can two transactions that update the same single row deadlock?
Long-running transactions: risks & guards
A long open transaction holds locks and old snapshots, which blocks others, bloats storage and can stall replication and DDL.
- Lock contention: rows or tables it touched stay locked, so other writers queue behind it; a waiting DDL then blocks every new query.
- MVCC bloat: Postgres VACUUM cannot remove dead tuples newer than the oldest open snapshot; InnoDB cannot purge undo (
History list lengthgrows), slowing reads. - Idle in transaction sessions (app opened a tx then went to do an HTTP call or crashed without closing) are the most common culprit.
- Replication & recovery: huge transactions produce big log bursts, delay replicas, and take long to roll back on failure or crash recovery.
- Guards: Postgres
idle_in_transaction_session_timeout,statement_timeout,lock_timeout,transaction_timeout(Postgres 17+); MySQLinnodb_lock_wait_timeout,max_execution_time(SELECT only). Monitorpg_stat_activity/information_schema.innodb_trx. - For big data changes, batch them (e.g. 1,000–10,000 rows per transaction) instead of one giant
UPDATE.
Interview questions
- What problems does a long-running transaction cause?
- What does 'idle in transaction' mean in Postgres and why is it bad?
- How would you update 50 million rows safely?
Distributed transactions & real scenarios
Distributed transactions: 2PC, sagas & outbox
Across several databases or services you either coordinate one atomic commit (2PC) or accept eventual consistency with sagas and reliable messaging.
- Two-phase commit (2PC): a coordinator asks every participant to PREPARE (make the work durable and promise to commit); if all vote yes it sends COMMIT, else ROLLBACK.
- 2PC is blocking: if the coordinator dies after participants prepared, they hold locks until it recovers ('in-doubt' transactions). It also adds latency and couples availability. Implemented by XA (MySQL
XA START/PREPARE/COMMIT), PostgresPREPARE TRANSACTION/COMMIT PREPARED, MSDTC. - Saga: a sequence of local transactions, each publishing an event or command for the next; on failure, run compensating transactions to undo earlier steps (refund, release stock). Choreography (events) or orchestration (a central coordinator).
- Sagas give no isolation: other requests can see intermediate states. Countermeasures: semantic locks (status = 'PENDING'), commutative updates, re-reading values, ordering steps so the riskiest is first.
- Dual-write problem: writing to the DB and publishing to Kafka are two systems; either can fail after the other. Transactional outbox fixes it: write the event to an
outboxtable in the same local transaction, and a relay (poller or CDC like Debezium) publishes it. - Delivery from an outbox is at-least-once, so consumers must be idempotent (dedupe by event id, or an
inboxtable).
Interview questions
- How does two-phase commit work and what is its weakness?
- What is the saga pattern?
- Choreography vs orchestration sagas?
- What is the transactional outbox pattern and why is it needed?
Choosing isolation: bank transfer, inventory, seat booking
Pick the cheapest technique that makes the invariant impossible to break: atomic updates, constraints, row locks, or Serializable with retries.
- Bank transfer: guard the debit in SQL (
… WHERE balance >= :amt) and check the row count, or lock both rows in id order withFOR UPDATE. Read Committed is enough with these. Add an idempotency key so a retried request does not transfer twice. - Inventory: never read stock into app memory and write it back. Use
UPDATE stock SET qty = qty - :n WHERE sku = :s AND qty >= :nand check rows affected; or aCHECK (qty >= 0)constraint as a backstop. - Seat booking: make the database enforce it with a UNIQUE (show_id, seat) constraint. For time ranges (rooms, doctors) use a Postgres exclusion constraint or Serializable, because 'check then insert' is a phantom/write-skew trap.
- Invariants across rows (at least one doctor on call, total budget ≤ limit): use Serializable with retry, or lock a shared parent row (
SELECT … FROM shift WHERE id = :s FOR UPDATE) to serialize the decision. - Reports and dashboards: Repeatable Read / snapshot (or a read replica) for a consistent picture without blocking writers.
- General rule: start at the default Read Committed, push correctness into single atomic statements and constraints, and raise isolation only for the transactions that need it.
Interview questions
- How would you implement a bank transfer safely?
- How do you prevent overselling the last item in stock?
- Two users click 'book seat A1' at the same moment. How do you guarantee one wins?
- When would you actually choose Serializable?