Skip to content

Checkpoint: recover a background pipeline

11 min reading

Resolve worker loss, duplicated delivery and replay in one diagram

Page details

System Design · Move work through time

11 min reading · 24 min with practice

Sources

Published · Last edited:

Prerequisite: Give events identities and reason about order. For basics, use the independent System Design foundations.

More
20px

Hypothetical scenario. Northwind’s recovery exercise repeats an intent publication, loses an acknowledgement after an effect, and delivers an older product version late. Maya asks the team to explain the final search record from the accepted edits rather than from the number of messages consumed.

Dev: “Several deliveries occurred for the same change.”

Priya: “Which ones created new effects, and which only repeated an existing obligation?”

Before opening the worked review, predict the final state and the unfinished work. Connect intent, publication, attempts and effects in one ledger. Keep independent projections’ progress separate and retain evidence for outcomes that remain uncertain.

Which accepted obligations must the final state explain?

Product edits commit with durable downstream intent in the selected local database boundary. Search and activity have independent progress because both require the relevant changes. Image readiness follows its separate verification and publication workflow. The seller’s acceptance response does not claim that every projection is already ready.

Search updates are complete representations identified by product, source version and projection schema version. The selected target contract rejects an older source version from replacing a newer one. This is a required effect-boundary rule to establish in the implementation, not a property inferred from a queue’s name.

Scheduled cleanup has its own occurrence identity and ownership generation. It cannot delete from an obsolete work list merely because a prior lease once existed. The queue pipeline and the cleanup scheduler share recovery vocabulary without turning their different effects into one universal retry policy.

Predict the final state from the delivery sequence

Choose four accepted logical projection updates: product P version 8, product P version 9, product Q version 3 and product R version 1. All belong to the same selected projection schema. The source ordering establishes that P version 9 supersedes P version 8.

For this hypothetical exercise, inspect six deliveries in order. P8 applies, then P9 applies. Q3 applies, but its worker loses the acknowledgement. Q3 is redelivered. R1 applies. Finally, a duplicated publication of P8 reaches the worker. Assume every required protected target operation is available and behaves according to the declared contract.

Before continuing, write the final version for P, Q and R. Decide which two deliveries should not create another version advance. Also name what record would remain unresolved if the target operation timed out instead of returning inspectable completion evidence.

Reconcile accepted intents with protected effectsFour logical updates produce six deliveries. Durable intent connects the source to publication. A worker checks logical identity and source version at the effect boundary. Search progress and unresolved outcomes are compared with the accepted intent ledger, separately from broker depth.4 logical updatesDurable intents6 deliveriesAttempts / duplicatesProtected targetIdentity + versionReconcile actual completionKeep uncertainty visible
Count deliveries, logical operations and final records separately.

Close the pipeline with an obligation ledger

Hypothetical scenario. Use the existing four accepted updates P8, P9, Q3 and R1. The final projection contains P9, Q3 and R1. P8 was a valid historical transition later superseded by P9; absence of P8 as a current row is not lost work. Conversely, a delivery disappearing from the broker is not proof of a target transition.

Close the pipeline with an obligation ledger — selected design evidence
ObligationFinal evidenceDisposition
P8P9 includes later source stateSuperseded under full-state rule
P9target applied version 9Protected-complete
Q3same effect on redeliveryProtected-complete
R1target applied version 1Protected-complete
The final outcome ledger accounts for accepted intentions; attempts are supporting events, not extra obligations.The final outcome ledger accounts for accepted intentions; attempts are supporting events, not extra obligations. Accepted intent to Delivery attempts: durable dispatch; Delivery attempts to Explained outcome: effect / supersession evidence.Accepted intentDelivery attemptsExplained outcomedurable dispatcheffect / supersession evidence
The final outcome ledger accounts for accepted intentions; attempts are supporting events, not extra obligations. Enlarge the diagram to inspect its labels; the surrounding records and explanation give the text alternative.

Give each obligation a state such as pending, protected-complete, superseded-under-contract or unresolved. Attempts retain their own identities and errors. The target version rule explains the late P8 delivery, and the stable operation identity explains Q3's redelivery after its lost acknowledgement. Neither should create a new logical obligation.

Recovery has a service envelope. This checkpoint has six deliveries for four logical jobs, giving 6 ÷ 4 = 1.5 deliveries per job. Under the selected equal-cost mix, three attempts per second support 3 ÷ 1.5 = 2 logical completions per second, leaving 2 − 2 = 0 net recovery margin with continuing arrivals. The earlier 1.25-attempt mix is a different assumption. Replay must preserve room for ongoing work and must not conceal an old unresolved item behind newer completions.

Work the recovery ledger

Hypothetical worked example. The six deliveries represent four accepted logical operations. P8 and P9 each advance P when first processed. Q3 and R1 advance their respective records. The repeated Q3 recognizes the already established operation. The late P8 cannot overwrite P9 under the selected source-version rule.

There are 6 − 4 = 2 non-advancing deliveries and four version advances in this particular sequence. Final records are P9, Q3 and R1. Three final product records do not imply only three logical updates occurred: P passed through two accepted versions.

The two repeated deliveries also have different causes. Q3 was redelivered after an acknowledgement was lost. P8 was published again by the dispatcher. Protecting only one transport stage would not cover both. Their shared logical identity and target contract connect these paths to the same intended work.

Using the selected five-hundred-byte event payload from the previous lesson, four source records contain 4 × 500 = 2,000 payload bytes. Six deliveries transport 6 × 500 = 3,000 payload bytes before framing and other traffic. The extra selected delivery payload is 3,000 − 2,000 = 1,000 bytes. Retained history size and delivery traffic are different counts.

Revisit the recovery margin under this failure mix

This sequence has 6 ÷ 4 = 1.5 deliveries per logical operation. Suppose, purely for a revised capacity exercise, that the same mix continues with equal-cost attempts. At three attempts per second, logical completion capacity is 3 ÷ 1.5 = 2 per second.

With two incoming logical jobs per second, net recovery margin is 2 − 2 = 0. A pre-existing hundred-job backlog does not drain under that fixed-rate model. This revises the earlier 1.25-attempt assumption instead of pretending every retry pattern has the same capacity consequence.

If selected attempt capacity increases to five per second, logical capacity becomes 5 ÷ 1.5 = 10/3 per second. Net margin is 10/3 − 2 = 4/3 per second. The hundred-job backlog then takes 100 ÷ (4/3) = 75 seconds to empty under the stated model. Actual attempt costs and available downstream capacity still need measurement.

Classify uncertainty before retrying

The worked sequence assumed inspectable target outcomes. A timeout after dispatch is different: the effect may exist even when the worker lacks its response. Retain the original logical operation and inspect the target’s supported identity or status evidence before selecting the next transition.

A worker restart should not turn unresolved Q3 into a new Q4 merely to obtain another identifier. A new source version means a new accepted product change, not another attempt to learn an earlier result. Preserve source history and diagnostic attempts separately.

Likewise, moving an invalid message to a dead-letter destination does not satisfy the original intent. The ledger should classify it as requiring correction, cancellation under an explicit rule, supersession or another recovery decision. Completion requires the effect’s actual meaning.

Review independent progress

Search completion cannot establish activity completion, and neither establishes image readiness. Each required responsibility needs observable progress tied to the original change. The transport can retain one event history while separate consumers fall behind for different reasons.

For a rebuild, inspect the source snapshot or retained history boundary, compatible schema interpretation and removal semantics. Replaying old products without their later withdrawal information can produce a fast but invalid view. The search eligibility rule remains in force during recovery.

In the wild: acknowledgements establish bounded facts

RabbitMQ’s confirmation and acknowledgement documentation provides concrete evidence about producer and consumer interactions with the broker. It is useful for locating the Q3 redelivery window. It does not establish that Northwind’s target enforced a source-version rule or that all independent projections finished.

The scheduling side has a similarly bounded contract. Kubernetes CronJob documentation describes its scheduling policy; application cleanup authority and object eligibility still need their own enforcement. A review should connect these mechanisms without expanding their documented claims.

When the broker is green and the workflow is unfinished

Hypothetical failure scenario. All queue deliveries are acknowledged, but a worker acknowledged one update before its target effect completed. Another accepted edit never left the outbox. Broker depth reaches zero while search misses both obligations.

The missing evidence is the reconciliation between accepted intents, dispatcher progress and applied or explicitly resolved effects. Retain that comparison independently of broker availability. An empty transport component is a useful observation, not an end-to-end completion certificate.

Write the module decision and its limit

Use this checkpoint to expose missing identity, authority and progress boundaries before increasing concurrency. It does not certify production throughput or replace an implementation-specific crash test. The selected sequence is a reasoning exercise with explicit assumptions.

Northwind’s decision is to retain one logical identity across all attempts, enforce the selected version rule at the effect, and reconcile every accepted obligation with its own completion state. The next module asks what failures the system is designed to tolerate. That failure model will determine which stronger consistency, transaction and consensus mechanisms are justified.

Challenge the proposed mechanism

Give a reviewer a broker depth of zero and six successful deliveries. What is still missing?

Reveal the design reasoning

The mapping from every accepted logical obligation to its protected effect or valid supersession, plus any uncertainty. Reconcile source versions and target evidence. Then check recovery capacity under the actual attempt mix.

Decision and reconsideration: Approve recovery only when accepted work is fully explained and continuing arrivals fit the recovery envelope.

Defend the recovery result

  1. Why do six deliveries leave only three final product records?

    Separate history from final state

    Four logical updates affect three products, with P advancing through versions 8 and 9. Two additional deliveries are non-advancing repeats. Final state and operation count describe different things.

  2. Can a three-attempt-per-second pool clear the old backlog under the selected 1.5-attempt mix?

    Check net useful completion

    No in the fixed-rate model. Three divided by 1.5 gives two logical completions per second, equal to arrivals. There is no positive recovery margin.

  3. Queue depth is zero. What evidence is still needed?

    Reconcile the original obligations

    Compare accepted intents, publication and protected effects for each responsibility. Missing publication, early acknowledgement or unresolved external outcomes can all survive an empty broker.

The checkpoint can reconcile known effects, but a missing response can leave the effect itself unknown. Page 25 changes that observation and asks which failure the caller can actually establish.

Northwind decision log

Reconcile accepted logical operations with effects, not delivery counts alone.
Recalculate capacity when retries change the attempts-per-operation mix.
Carry unresolved outcomes and authority assumptions into the failure-model module.

Go deeper: persistent state and external effects