State safety
Name the state that survives restart and the write that makes retry safe.
A Staff scheduler answer with time buckets, near-term delay queues, leases, zombie fencing, retries, backoff, poison queues, idempotent handlers, and exactly-once illusion.
Follow the Week 4 delivery pattern: blank-page first, source reading second, DDIA decision third, spoken close, contiguous algorithm practice, evening recall.
| Time | Block | Required output |
|---|---|---|
| 08:30 | Wake + setup | Open this page, start the board, write the day question: How do 2-second precision, 10k jobs/sec, and at-least-once execution fit together? |
| 08:50—09:00 | Board set | List entities, queues, leases, retry states, dedupe keys, metrics before reading. |
| 09:00—10:05 | Blank-page attempt + Hello reading | Rehearse the three Hello deep dives. For each one, write the bottleneck, mechanism, failure window, recovery, and metric: 2s precision, 10k jobs/sec, at-least-once execution. |
| 10:05—10:45 | Deep dive + DDIA decision | Build the lease story: scanner moves due executions into a near-term queue; worker claims with token and deadline; heartbeat extends; completion uses conditional token match; expired leases reappear; retries use exponential backoff plus max attempts; poison messages stop infinite harm. |
| 10:45—10:55 | Spoken close | Say the exact-once line cleanly: the scheduler guarantees at-least-once delivery and externally idempotent effects, not magic exactly-once execution. |
| 14:30—16:15 | NeetCode Heap/Priority Queue | Complete contiguous slots W8-H10—W8-H12; capture invariant and bug risk for each. |
| 20:30—21:15 | Recall / Q&A / mock | Use Staff Q&A, lecture assets, or mock script for the day's system. |
Read only the listed Hello Interview headings for today's assignment. Every link is a direct day-page anchor.
Use exact sections only from Ch5, Ch9, and Ch12.
| Chapter | Exact DDIA decision section | Concrete Week 8 use |
|---|---|---|
| Ch9 | 分布式锁和租约 | Workers lease an execution; they never own it forever. |
| Ch9 | 进程暂停 | Zombie workers are normal; lease expiry and fencing decide whose completion counts. |
| Ch12 | 确认应答与重新传递 | Redelivery is expected, so handlers and completion writes must be idempotent. |
| Ch12 | 幂等性 | Exactly-once is an illusion built from idempotency keys, conditional writes, and dedupe windows. |
Three contiguous slots today. Keep one invariant and one failure mode per problem.
| Slot | Problem | Pattern | Invariant / bug risk | Time · Space |
|---|---|---|---|---|
| W8-H10 | Reorganize String | max-heap with cooldown | A character cannot re-enter the heap until one different char is placed. | O(n log a) · O(a) |
| W8-H11 | Meeting Rooms II | min-heap of end times | Room pressure is the count of active intervals. | O(n log n) · O(n) |
| W8-H12 | Single Threaded CPU | available-work heap | Push all work whose enqueue time is <= current clock before selecting. | O(n log n) · O(n) |
One compact artifact is enough if it proves mechanism depth.
Name the state that survives restart and the write that makes retry safe.
Use a worker crash, zombie lease, redelivery, poison message, stale robots decision, or duplicate price event.
Attach lag, retry rate, duplicate suppression, stale lease reject count, host politeness violation, or alert freshness.