Shard Growth 20 → 200
The cutover controller crashes between copy validation and routing activation.
Topic tools
Layout updated
Prompt
The cutover controller crashes between copy validation and routing activation.
Moving a is moving a live shop: copy the shelves, replay sales that happened during the move, then switch the address once.
Constraints
- Do not lose writes or deletes during migration.
- Keep one write owner for each data range.
Think first
Take five minutes to state the failure, the evidence you need and your first safe move.
Staged reveal
First move
A versioned routing authority owns the range assignment.
What to check
Compare durable migration state, routing and catch-up .
Recovery
Resume from a durable , keep a single write owner and validate the installed before reopening writes; do not infer completion from copied bytes alone.
What you give up
Writing to both sides needs a durable recovery log and conflict rules. Moving data also competes with foreground reads and writes, so throttle it.
Architecture and technical reference
High-level design
- Compute
- State
━━ Synchronous┄┄ Asynchronous···· Recovery / control▧ Fault
Each arrow is one interaction. Request, background and recovery branches are not one linear transaction.
Read the 5 flow steps
Problem statement
Move a live dataset from 20 to 200 shards while writes continue. What proves the new owner is ready?
Functional requirements
- Move data from existing shards to new shards.
- Copy updates and deletes made during the move.
- Switch requests to the new owner after verification.
Non-functional requirements
- Do not lose writes or deletes during migration.
- Keep one write owner for each data range.
Entities
| Entity / logical owner |
|---|
| Authoritative state |
API design
| Operation / input | Response and retry contract |
|---|---|
Decision contract | Identify acceptance, retry identity, version/ and the response on uncertainty. |
High-level design component walkthrough
Consistent-Hash Router
+ version
Why, tradeoff and connected operations
Make ownership/version changes explicit; downstream resources must reject stale owners.
Tradeoff: Mapping version split causes misroutes
Connected operations: old map; publish new map
RocksDB-backed KV / 20 Shards
Read/write owner
Why, tradeoff and connected operations
Illustrative custom sharded : embedded RocksDB per ; versioned routing controls ownership. Partition durable state by the documented lookup key; consistency follows the explicit replication policy.
Tradeoff: Dual load during migration
Connected operations: old map; Pass validated input
Migration Workers
Copy + catch up changes
Why, tradeoff and connected operations
Isolate this operation so it can scale and fail independently from storage.
Tradeoff: Concurrent writes require catch-up
Connected operations: Pass validated input; Persist state
RocksDB-backed KV / 200 Shards
Verify copied state
Why, tradeoff and connected operations
+ log catch-up before cutover; RocksDB itself does not coordinate distributed ownership. Partition durable state by the documented lookup key; consistency follows the explicit replication policy.
Tradeoff: Need verify completeness before cutover
Connected operations: Persist state; verified
Cutover Controller
ownership
Why, tradeoff and connected operations
Make ownership/version changes explicit; downstream resources must reject stale owners.
Tradeoff: / rollback complexity
Connected operations: verified; publish new map
Engineering control room
Deep dives — decisions, failures and recovery
Open a deep dive to follow the steps, try an example and see how recovery works.
Tradeoffs and alternatives
| Decision | Tradeoff / alternative and recovery implication |
|---|---|
| Know which is allowed to write | Writing to both sides needs a durable recovery log and conflict rules. Moving data also competes with foreground reads and writes, so throttle it. |
| Copy, catch up and then switch ownership | Redirect or reject stale clients. If rollback is needed after new writes, reconcile them first; simply changing the pointer can lose accepted updates. |
| What happens if a region fails? | Keeping old copies longer improves recovery options but increases storage and deletion-safety work. |
| Check a moved before switching traffic | Longer validation and old-copy increase time/storage cost but reduce difficult post-cutover data loss. |
Production scars & failure modes
The cutover controller crashes between copy validation and routing activation.
Look for: Compare durable migration state, routing and catch-up .
Recovery and invariant: Resume from a durable , keep a single write owner and validate the installed before reopening writes; do not infer completion from copied bytes alone.
| Component / failure | Impact | Recovery mechanism | Alternative / tradeoff |
|---|---|---|---|
| Primary failure / race | Move a live dataset from 20 to 200 shards while writes continue. What proves the new owner is ready? | Copy a consistent , replay mutations/deletes to a verified , then publish a fenced cutover. Keep old copies through the safety window. | Dual-writing without a recoverable log creates partial success. Rebalancing consumes foreground I/O and needs throttling. |
| Recovery follow-up | A stale client writes to the old owner after cutover; then the new fails. Define redirection, and a safe rollback. | Copy a consistent , replay mutations/deletes to a verified , then publish a fenced cutover. Keep old copies through the safety window. | State the guarantee you relax and how you detect recovery. |
90-second interview summary
For growth, I would distinguish copying data from transferring write authority. A versioned placement service identifies the current owner of each range. Migration workers record a consistent and durable progress through the mutations that arrive while the is copied.
The target receives the , then replays updates and deletes to a verified catch-up boundary. Checksums, version coverage and deletion state matter; matching row counts or copied-byte totals do not prove that the target has the required logical history.
Cutover establishes a fenced new placement under a controlled handoff. Old routing caches receive redirects or rejections rather than permission to continue writing to the old owner. A crashed controller resumes from durable migration state instead of inferring completion from files on disk.
I would retain old data through a safety window, but rollback after new writes also needs ; a pointer change alone can lose accepted updates. Regional promotion must use the same placement authority. Metrics include oldest transfer lag, validation errors and stale- writes. The tradeoff is temporary duplicate storage and careful cutover coordination in exchange for growing from 20 to 200 logical shards without dual owners or lost deletes.
Explain it without looking
Explain know which is allowed to write
Reveal answer
A versioned routing authority owns the range assignment.
Having a copied file does not make the target a writer, and a cached old route does not authorize the source after cutover.
Writing to both sides needs a durable recovery log and conflict rules. Moving data also competes with foreground reads and writes, so throttle it.
Explain copy, catch up and then switch ownership
Reveal answer
Replay updates and deletes to a checked position before publishing the new owner.
A bulk-copy job can finish while recent writes are still missing from the target.
Redirect or reject stale clients. If rollback is needed after new writes, reconcile them first; simply changing the pointer can lose accepted updates.
Explain what happens if a region fails?
Reveal answer
Recover the current owner before continuing a partially completed move.
Data movement and failover must agree about which copy may accept writes.
Keeping old copies longer improves recovery options but increases storage and deletion-safety work.
Explain check a moved before switching traffic
Reveal answer
Verify logical state and deletion coverage before declaring migration complete.
Migration correctness is about one complete logical history, not a successful bulk-copy job.
Longer validation and old-copy increase time/storage cost but reduce difficult post-cutover data loss.
Revision checklist
Revision checklist
- Reconstruct know which is allowed to write: A versioned routing authority owns the range assignment.
- Reconstruct copy, catch up and then switch ownership: Replay updates and deletes to a checked position before publishing the new owner.
- Reconstruct what happens if a region fails?: Recover the current owner before continuing a partially completed move.
- Reconstruct check a moved before switching traffic: Verify logical state and deletion coverage before declaring migration complete.
- Name the authoritative state, boundary, retry identity and failure-domain durability guarantee.
- Explain one alternative and exactly which guarantee you would relax.
- Redraw the request and recovery paths without looking; mark what required a hint.
On this page
- Prompt
- Constraints
- Think first
- Staged reveal
- High-level design
- Problem statement
- Functional requirements
- Non-functional requirements
- Entities
- API design
- High-level design component walkthrough
- Engineering control room
- Deep dives — decisions, failures and recovery
- Tradeoffs and alternatives
- Production scars & failure modes
- 90-second interview summary
- Explain it without looking
- Revision checklist