Skip to content

A job-execution platform under worker loss

11 min reading

A final core review of retries, isolation, fairness and durable results

Page details

System Design · Compose complete systems

11 min reading · 26 min with practice

Sources

Published · Last edited:

Prerequisite: A job-execution platform: submit, isolate and observe. For basics, use the independent System Design foundations.

More
20px

Hypothetical scenario. A Northwind conversion worker uploads output and stops sending heartbeats. A replacement begins; the original later resumes and tries to complete the job. Dev wants prompt recovery, while Priya asks which attempt may publish a result or send an external notification.

Maya: “We need one trustworthy job outcome.”

Dev: “Silence can justify recovery without proving that the earlier process has stopped.”

Finish the core course by revising ownership, effects, isolation and fairness under worker loss. Keep the baseline capacity assumptions while accounting for lost slots and repeated work. The following AI specialization is optional; it is not needed to complete this platform design.

What does the worker’s silence permit us to conclude?

A lease gives the scheduler a bounded ownership record. Once that record expires, the service can authorize a replacement attempt. It cannot infer that the previous process has vanished: a pause, partition or delayed heartbeat can produce the same observation. The old process may resume with files and credentials still in memory.

Make accepted result publication conditional on the current job generation and attempt identity. An old worker can upload an unaccepted artifact, but cannot replace the accepted pointer after ownership changes. Storage naming and garbage collection must tolerate such leftovers without exposing them as successful results.

Cancellation uses the same discipline. Record a durable cancellation request, stop admitting further attempts and revoke available capabilities where supported. A stop signal is an effort to terminate execution, not evidence that an external request did not happen. Describe cancelled, stopping and uncertain states honestly where the workload needs them.

The effect target needs its own duplicate rule

A guarded result pointer protects the platform’s record. It does not automatically protect an email gateway, payment endpoint or third-party upload that a worker calls. Define which effects are permitted, their stable business identity and how their targets handle duplicates or old generations.

For the conversion baseline, make workers produce immutable artifacts without sending user notifications directly. A separate durable notification obligation follows accepted result publication. Its consumer still needs a stable effect identity and a target-specific recovery rule. Moving the call to another queue does not erase the uncertain interval around the call.

Where an external target cannot reject stale attempts or recover a stable operation, choose a narrower product contract. Require manual reconciliation for uncertain high-impact effects, or redesign the step so that it prepares an artifact for later approval. Do not claim exactly-once execution merely because only one job row is marked successful.

A replacement fences result acceptance, not every external effectA replacement gets a new generation while the old worker may continue. The current attempt guards result publication. External effects require separate identities and reconciliation contracts.Lease expiresNew attempt generationOld worker may resumeGuarded result commitExact current attemptImmutable outputAccepted publicationSeparate effect identityReconcile uncertainty
A replacement fences result acceptance, not every external effect

Recover useful work without admitting a stale winner

Hypothetical scenario. Worker generation 7 loses contact. Generation 8 is admitted for the same job, then the old worker resumes and uploads a plausible result. Both outputs may exist, but only the current protected result transition can select the winner. Deleting the old worker's process record is not enforcement at result acceptance.

Recover useful work without admitting a stale winner — selected design evidence
Failure conditionSafe stateProgress obligation
Old worker resumesGeneration 7 result rejectedGeneration 8 may complete
Slots lostAccepted jobs remain durableDebt / admission policy
Shared store stallsNo invented completionBound queued resources
Tenant retry stormOther tenant budgets retainedFair recovery admission
The protected result authority, not process liveness, determines which completion becomes current.The protected result authority, not process liveness, determines which completion becomes current. New worker 8 to Result authority: 1 · current attempt 8; Old worker 7 to Result authority: 2 · stale candidate rejected; New worker 8 to Result authority: 3 · input-bound accepted result.Old worker 7Result authorityNew worker 81 · current attempt 82 · stale candidate rejected3 · input-bound accepted result
The protected result authority, not process liveness, determines which completion becomes current. Enlarge the diagram to inspect its labels; the surrounding records and explanation give the text alternative.

Preserve the earlier nine-slot survivor model: eighteen attempts per minute divided by the selected 1.2 attempts per useful completion gives fifteen useful jobs per minute. With eighteen new jobs per minute, debt grows by three per minute. Retrying faster cannot close a useful-capacity deficit; admission, restoration of capacity or a permitted workload change must do so.

Fairness and shared dependencies belong in the failure envelope. One tenant's retry debt must not occupy every worker or result-store connection. Partition admission budgets, bound recovery concurrency and measure oldest accepted work. A current result token does not protect arbitrary external effects performed by the job; those require their own target-side identity or capability protocol.

Revisit capacity after losing slots

Hypothetical worked example. Lose three of the twelve selected worker slots. Remaining slots are 12 − 3 = 9. At the selected thirty-second mean occupancy, attempt capacity is 9 ÷ 30 = 0.3 attempts per second, or eighteen attempts per minute. Keep the selected retry mix of 1.2 attempts per useful completion: 18 ÷ 1.2 = 15 successful jobs per minute.

With eighteen new logical jobs per minute, retained work now grows at 18 − 15 = 3 jobs per minute. Over ten minutes it grows by 3 × 10 = 30 jobs, excluding any earlier backlog. A retry policy cannot restore capacity that is absent; extra retries can consume the remaining slots and make the useful rate worse.

After restoring all twelve slots, selected useful capacity returns to twenty completions per minute. Net drainage is 20 − 18 = 2 jobs per minute, so the extra thirty jobs take 30 ÷ 2 = 15 minutes to drain under those fixed assumptions. The ten-minute incident therefore does not imply a ten-minute return to an empty queue.

For ownership, select attempt generation seven before the loss and eight after reassignment. The difference 8 − 7 = 1 identifies a later generation; it is not itself a fence. The result authority must compare the submitted generation with its current accepted state at the commit boundary.

In the wild: controller completion is a narrower promise

The Kubernetes Job documentation describes replacement and retry behavior and cautions about duplicate execution. Use it to reason about process management, then inspect application effects separately. The documentation is evidence for controller semantics, not proof that Northwind’s workflow or notification contract is complete.

An operational review should ask which state survives deletion of a worker and which accepted obligations survive loss of the scheduler. Rebuild views from durable records, restore compatible configuration and verify that restored generations cannot authorize old attempts. A backup containing readable rows can still be unsafe if it resurrects obsolete ownership.

An old process wins by arriving last

Hypothetical failure scenario. The replacement finishes a valid artifact and publishes its result. The old process resumes and overwrites a shared output filename with an earlier partial artifact, then emits a success notification. The job dashboard continues to show one success, masking the corrupted result and duplicate effect.

Use immutable attempt-scoped output and a conditional authoritative pointer. Prevent old credentials from writing broad shared locations where feasible. Keep publication notifications downstream of accepted result state. Investigate and collect leftover artifacts without treating their presence as a reason to reverse the accepted outcome.

Protect recovery capacity as a shared resource

A burst of failed jobs can monopolize a worker pool if retries receive unlimited priority. Bound attempts, use backoff with jitter where appropriate, and allocate capacity across tenants and job classes. Reserve room for fresh work only if that policy fits deadlines and fairness; otherwise state the priority explicitly.

Separate poison inputs from transient failures. A malformed document that repeatedly exhausts parser memory should reach a terminal or quarantined state with bounded retained evidence. Sending it back indefinitely is neither recovery nor fairness. The platform must also cap output and log volume so that diagnosing failure does not exhaust storage.

Completion metrics need the same units used in planning. Count useful logical outcomes separately from attempts and unresolved effects. Track queue age by tenant and class, not only a global mean. If one tenant waits behind repeated failures, a healthy fleet average does not satisfy that tenant’s contract.

Defend the complete core design

Pause before the optional modules and redraw the platform without component brands. Follow one submission from caller intention through acceptance, scheduling, isolated execution, result publication and notification. At each arrow name the durable evidence, timeout behavior and authority check. Then map the selected technologies back onto those responsibilities.

The core course is complete when the design can explain both a successful path and an ambiguous failure without changing its workload units or silently weakening an invariant. The optional AI pages reuse this method for model execution and evidence handling. They add new prerequisites rather than retroactively making machine learning necessary for the crawler or job platform.

Challenge the proposed mechanism

Recovery consumes the same surviving resources as new work and must share explicit budgets.Recovery consumes the same surviving resources as new work and must share explicit budgets. New jobs to Tenant admission: bounded accepted obligations; Tenant admission to Surviving workers: new work + recovery grants.New jobsTenant admissionSurviving workersbounded accepted obligationsnew work + recovery grants
Recovery consumes the same surviving resources as new work and must share explicit budgets. Enlarge the diagram to inspect its labels; the surrounding records and explanation give the text alternative.

An old attempt sends an external email before its result is rejected. Did result fencing protect the email?

Reveal the design reasoning

No. The fence covered the result transition only. Give that external effect its own approved identity and target protocol or remove that capability. State the actual authority boundary rather than claiming platform-wide once-only execution.

Decision and reconsideration: Combine fenced results with useful-capacity and tenant budgets. Review every external effect separately from job completion.

Check the design against changed conditions

  1. The old lease expired. Can the old process still call a service?

    Reason through the consequence

    It may still execute. Lease expiry changes authority records; enforce current ownership at protected effects and restrict capabilities rather than assuming the process disappeared.

  2. Nine slots provide eighteen attempts per minute. Can they serve eighteen successful jobs per minute with 1.2 attempts per success?

    Reason through the consequence

    No. The selected useful rate is fifteen jobs per minute, so eighteen arrivals grow retained work by three per minute.

  3. One final job row says success. Does that prove a notification happened once?

    Reason through the consequence

    No. Result publication and external effects have different authorities. Inspect the notification’s stable identity, target behavior and reconciliation evidence.

This closes the core System Design path. Optional page 61 reuses its workload, admission and deadline reasoning for model serving, with explicit GenAI prerequisites rather than hidden assumptions about model internals.

Northwind decision log

Fence accepted results and retain old-attempt evidence safely.
Bound retries and reconcile effects without inventing a terminal outcome.
Core complete; continue to optional AI architectures or communication practice.

Go deeper: Recovery when execution outlives ownership