Interview: the write succeeded, the next read shows an empty cart

A QUORUM write retried at ONE. Tunable consistency, sloppy quorums and hinted handoff, read repair, and Merkle-tree anti-entropy.

More on Ticket interviews

Keep learning

Overview

write consistency W Write quorum read consistency R Read quorum hinted handoff Hinted handoff counts toward W A B C are the owners · H is a hint kept on some other node A B C are the owners write only read only both The read misses every node that took the write. The cart looks empty despite a 200. A hint on H counted toward W. H is not an owner, so R + W > N no longer guarantees overlap.

The write succeeded. The next read shows an empty cart.

Writes said “saved”, yet the next read showed the old cart. This tests tunable consistency, sloppy quorums and replica repair. hinted handoff read repair Merkle trees eventual consistency Cart saved (200), next read shows the old cart. Retry silently downgraded writes from QUORUM to ONE.

Customers say items vanish right after Add to cart

~15% of carts during last night’s node outage. Items reappeared within an hour after the node was replaced. bad reads node down Restated: the write landed somewhere the next read did not look.

QUORUM on paper. What ran in practice?

Any quorum failure silently saves to one replica. The caller sees success. Down 4 h, hints last 3 h: the last hour’s hints were dropped. No read repair. Replica A Replicas B + C PUT cart @ QUORUM B is down → UNAVAILABLE retry PUT @ ONE silent downgrade stores new cart only copy GET @ QUORUM → old cart read B + C, both missed it

Check that the sets actually intersect

Did the write fail? Check the API status. Clients got 200. The bug is where the data went. Is QUORUM what ran? Read cart_store.ts. The retry rewrites at ONE. Many “QUORUM” writes hit one replica. Can a later QUORUM read miss that copy? 1 + 2 is not more than 3. The read can pick the two that missed it. Why did the data heal an hour later? Read cluster.yaml. Hints replayed, or a background repair ran. Hints past 3 h were dropped.

Fail the write that you cannot place on a real quorum

PUT @ QUORUM no downgrade 503 to client client retries GET @ QUORUM An honest failure beats a 200 that later reads can’t see. Forces the write and next read to overlap on owners. Treats hinted or single-node writes as retryable failures. Adds the exact test that would catch the downgrade. Keeps the change small: no new nodes.

No AI from here

When does R + W > N mean the read sees the write? When the overlap is among the real owners and the reader picks the newest copy. If R + W > N, every read set shares a node with every write set. A copy parked on a non-owner does not count. sets intersect owners only newest version wins write ✓ write ✓ · read ✓ read ✓ What is hinted handoff, and how does it break that proof? sloppy quorum If an owner is down, another node holds a hint and replays it later. Counting hints is a “sloppy quorum”: reads of real owners can miss. Hints expire. Long outages need a later repair. hint ≠ owner sloppy vs strict hint window Strict quorum W counts owners only. R + W > N guarantees overlap. Sloppy quorum W counts stand-in node H. Overlap no longer guaranteed. Read repair and Merkle trees both move bytes. What is each for? Read repair: on a mismatch, write the newest version to lagging replicas. Digest reads fetch hashes first, then the full row from the newest replica. read repair is on demand Merkle bounds comparison unread keys stay stale Read repair Triggered by a read. Fixes only that key. Merkle anti-entropy Background sweep. Finds any differing range. Only eventual consistency: replicas converge once writes stop. Session guarantees (read-your-writes, no going backwards) are per client. Linearizable means every later read, by anyone, sees the write. ONE/ONE is not. eventual vs linearizable session guarantees per client ONE/ONE has a gap Everyone sees it ONE / ONE ONE / ONE + session QUORUM / QUORUM A partition cuts one node off. What can you still serve? Pick per operation: stay correct or stay available, not both. That choice is the real content of CAP (consistency vs availability). For carts, a 503 beats a 200 that one side won’t see. partitions force a choice partial correct result 503 beats a lying 200

The sale wants writes to succeed when a node is down

What do you tell them? QUORUM for both, no downgrade. 503 if two owners are unreachable. Writes during one failure Surprise empty carts Keep the ONE fallback so the sale never sees a 503 More 200s, and guaranteed stale reads during outages. Support tickets become the fix. Fast reads that still overlap. But any one node down fails every add-to-cart. Writes survive two nodes down. But one slow node stalls every read.

Have one ready

Tell me about a stale read you could reproduce. What was promised vs what was seen. The quorum, retry or repair you changed. Stop a node, read via another coordinator.

Did you show these?

Found the retry downgrade R + W > N, and what N counts Read repair vs Merkle trees What ONE/ONE really promises 503 over a lying 200 Same quorum for write and read

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.