Interview: the member is active and the email went out twice
Two local ACID transactions are not one atomic change. Reorder the steps so the failure is repairable, or put the tables back in one service.
More on Ticket interviews
- Database Interviews in the AI Era: The Ticket Format
- Interview: the same job runs twice
- Deadlock Interview Question: Find and Fix It in SQL
- Slow Query Interview: One Keyword Made It 40× Slower
- Interview: rate limit is 2/min, 30 requests get through
- Interview: “just add an index” slowed ingestion
- Interview: “I changed my name, refresh shows the old one”
- Interview: importing 10M rows takes six hours
- Interview: everything got slow and the disk keeps growing
- Lost Update Interview: Wallet Balance Wrong Under Load
- Interview: API p99 jumps 10× every night at 2 am
- Interview: profile lookups got 40× slower, writes are fine
- Interview: inserts stall, and only one page is hot
- Interview: the write succeeded, the next read shows an empty cart
- Interview: inventory stayed locked after the coordinator restarted
- Interview: for four minutes, both regions took orders
- Interview: shoes show a 0% discount, then the report crashes
- Interview: March gained $50 after the deploy, and the months don’t add up
- Interview: the new branch’s dashboard takes 38 seconds
- Interview: the index is right there, make Postgres use it
- Interview: warehouse and checkout overwrite the same order
- Interview: the bestsellers report now takes nine minutes
- Interview: an analyst query locked checkout
- Interview: one shard is at 96% CPU and the other is idle
- Interview: the menu is slow, and the proposal is event sourcing
- Interview: four dashboards disagree about whether the database is slow
- Interview: checkout got slow the hour the warehouse job started
- Interview: the query is fast in staging and slow in production
- Interview: login looks up an email and reads the whole customers table
- Interview: the proposal splits one database into three shards
- Interview: the order page joins four tables on every view
- Interview: every page view is a read-write query on the leader
- Interview: Sarah and John both debit version 1
- Interview: the CTO read a blog post and wants to move Postgres to MySQL
- Interview: one table takes 50,000 writes a second, another feeds dashboards. Which engine for each?
- Interview: EU users wait on the ocean for every write, can both regions take writes?
- Interview: users search cars by color, but the table is sharded by car id
- Interview: we added a fourth node and most of the data moved
- Interview: two people book the same room at noon, both get a confirmation
- Interview: everything is on the strongest consistency and far requests crawl
- Interview: the order is saved, the message to search and email never left
- Interview: rename a column on a 600 GB table while 30 servers keep serving traffic
- Interview: orders go to 16 shards in 2 regions, what should the order id be?
- Interview: one celebrity posts, and every timeline in the app slows down
- Interview: 5,000 customers share one database, and one of them slows down everyone
Keep learning
Overview
Two databases, so two separate transactions. The member row is durable. The customer can sign in. DELETE pending fails The signup service timed out. The pending row is still there. pending row remains A job sees “pending” and sends the welcome email again. DELETE pending COMMIT The reversible step goes first. If this fails, no pending row means no resend. Recreate it. no pending row Worst case: “not pending, not active yet”. That is repairable. Activate a member Step order mark active, then delete delete pending, then mark active Members DB Signups DB Play step 1 Next step Show all = beats.length ? ( Still not one atomic commit. But the failure is now repairable, with no second email. Each database committed or failed alone. No ROLLBACK reaches the other database.
The member is active, and the welcome email went out twice
local ACID reorder steps don’t split yet New members get two welcome emails.
New members get two welcome emails
Member is active. Its pending_signups row is still there. The hourly job sees “pending” and sends the email again. The delete in the signups DB timed out. No error on the member. pending row still there Before: one database Activate + delete pending in one transaction. All or nothing. Now: two databases Two separate commits. One can succeed while the other fails. Restated: each side is durable. The business step is not atomic.
Four checks, in order
Does each write have a transaction? Read both services. Yes. Each is ACID inside its own database. Is the pair atomic? What undoes the member if delete fails? Nothing. The member database already committed. Is the dangerous step last? Which failure does the customer notice? Active-then-delete leaves a lie the job acts on. The reverse leaves a fixable gap. Does a distributed commit fix this? Count lock time and required uptime. Both services would hold locks until both agree. That is a new outage.
You choose the order and the repair. The model types it.
Delete pending signups DB · commit Set active members DB · commit re-insert pending + alert Job sends mail only if active AND no pending The safe order: undoable step first, and the job checks both facts. Defines the repair for the failure you can undo. Keeps “put the tables back together” as a real option.
Say these without the model
Both writes are ACID. Why is the operation not atomic? Either commit can succeed while the other fails. Neither database can undo the other. Isolation is local too: the job can see “active” and “pending” together. two transactions job sees the gap Members DB ACID inside ✓ Signups DB Both together No shared commit ✕ Job’s view Can see a half-done state When do you refuse to split the tables? When it must be all-or-nothing and no repair is acceptable. Keep both tables in one service until a repair exists. Splitting later is cheaper than an unneeded coordinator. Long processes use local commits plus undo steps, not long locks. repairable or not keep one database long work ≠ lock
Product wants a guarantee again
What do you tell them? Reorder, and make the job read both facts Failures no longer send mail and are repairable. You name the remaining gap out loud. Double emails Locks held Honest gap Two-phase commit across the two databases Both services hold locks until both agree. A rare double email becomes common lock pileups. Move both tables back into one service The original transaction works again. Right call if the rule is truly all-or-nothing.
Did you show these?
Each database still ACID The pair is not atomic Reordered for a repairable failure Job checks both facts Offered one service over 2PC
More courses
- Jobs, linked to lessons — Browse jobs where every requirement links to the chapter that teaches it. See how ready you are, how long the gap takes to close, and which listings look stale.
- Match a job post to courses — Paste a job post. Each skill is matched to a track here and put in learning order, foundations first.
- React patterns from open source — Patterns extracted from Material UI, Radix, React Aria, React Hook Form, Redux Toolkit, TanStack, and Next.js — not slides about hooks.
- System Design — Core concepts first (SQL vs NoSQL, CAP, indexing, replication, sharding), then designs grouped by what carries them: the database, Redis, Kafka, or many services.
- NestJS: build a real API — One ticket-booking API, built in order: a plain Node server first, then NestJS modules, validation, a real database, and the features real clients lean on.
- Microservices — Microservice patterns one diagram at a time: how to split a monolith, how services talk, and how data stays consistent without distributed transactions.
- Kafka — A beginner-to-senior path through event logs, reliable delivery, production operations, and disaster recovery.
- AI engineering for software engineers — Eight free reads, in order, for software engineers moving into AI: when to build an agent, how to build one, how to test it, and how the model works underneath.
- Frontend system design — How a UI is sliced when it is a product, not a page: ownership of state, cache, routes, and what happens when the network lies.
- TypeScript in depth — The type system as a design tool. Inference, narrowing, generics, and the errors that mean the model is wrong — not a catalog of utility types.
- CSS in depth — See the box, then the page. Visual chapters from the box model through Flexbox surprises, Grid, selectors, and units, then backgrounds, shapes, and visual effects, each with a playground.
- Accessibility — Foundations first (WCAG in plain words, semantic HTML, lists, alt text), then hands-on HTML labs, a full pass of WAI-ARIA 1.3, and a final fix-the-page challenge.
- Docker — What an image is, why layers cache, and how containers find each other on a network.
- Redis — Fifteen Redis patterns, one picture each: cache, session, lock, counter, rate limiter, queue, and when Redis is the wrong tool.
- Kubernetes — Kubernetes from zero to operators: why it exists, Pods, Deployments and Services, then configuration, networking, storage, scheduling, scaling and security.
- AWS — AWS networking in plain English. A VPC is a gated housing society: streets are subnets, the Internet Gateway is the main gate, and a route table is the signboard.
- Networking: the NetRoute game — NetRoute is a packet logistics game. You wire up computers, switches, routers, firewalls and gateways, set each device, and watch glowing packets travel. If a packet gets dropped, the game shows you which header field was wrong.