State safety
Name the state that survives restart and the write that makes retry safe.
A scheduler HLD that separates job definitions, schedules, execution instances, leases, attempts, and user-visible status.
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: What is durable state: the job definition, the scheduled occurrence, or the execution attempt? |
| 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 | Blank-page the scheduler: create job, update recurring schedule, store next fire time, scan due buckets, enqueue executable work, run worker, write attempt/status, expose monitor API. Then read Hello through HLD and update entity names. |
| 10:05—10:45 | Deep dive + DDIA decision | Name the state transitions: scheduled -> due -> leased -> running -> succeeded/failed/retry/dead. Store idempotency key, lease token, attempt number, not_before, and poison reason. User status reads should not depend on worker memory. |
| 10:45—10:55 | Spoken close | Explain why recurring schedules create execution instances instead of mutating one long-running job row. |
| 14:30—16:15 | NeetCode Heap/Priority Queue | Complete contiguous slots W8-H07—W8-H09; 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 |
|---|---|---|
| Ch5 | 持久化执行与工作流 | The workflow definition is separate from each execution instance. |
| Ch5 | 消息代理 | The dispatch layer decouples time discovery from worker execution. |
| Ch12 | 消息传递系统 | Execution messages must support acknowledgement and redelivery semantics. |
Three contiguous slots today. Keep one invariant and one failure mode per problem.
| Slot | Problem | Pattern | Invariant / bug risk | Time · Space |
|---|---|---|---|---|
| W8-H07 | Find Median From Data Stream | two heaps | All left items <= all right items, and sizes differ by at most one. | O(log n) · O(n) |
| W8-H08 | Merge K Sorted Lists | heap of list heads | Only the next head of each list belongs in the frontier. | O(n log k) · O(k) |
| W8-H09 | Design Twitter | heap merge of recency streams | News feed is a bounded k-way merge over followed users. | O(f log f) · O(f) |
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.