> ## Content Index
> Fetch the complete content index at: https://abundance.alloconomy.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Crash after the write
- URL: https://abundance.alloconomy.com/alloconomy/de-interview-crash-after-the-write/
- Published: 2026-11-22T05:07:39.000Z
- Updated: 2026-11-22T16:31:37.000Z
- Description: A worker writes dispatch D1, crashes before committing its input position, reprocesses D1, then receives genuine dispatch D2.
- Author: Sathya Narayanan
- Tags: Alloconomy, Data Engineering, Data Engineering Interview Field Guide, #web-only, #series-detail, #Import 2026-11-21 19:24, Pipelines that can recover

1. [Collection · 10 seriesThe Data Engineering Interview Field Guide](https://abundance.alloconomy.com/alloconomy/data-engineering-interview-field-guide/)
2. [Series opening · 3 essaysPipelines that can recoverSeries 7 of 10](https://abundance.alloconomy.com/alloconomy/de-interview-choose-what-the-source-must-retain/)
3. This essay2 of 3

Data engineering · 3 essays

Pipelines that can recover

Complete reading path · You are in Part 2 of 3
1. Part 1[Choose what the source must retain](https://abundance.alloconomy.com/alloconomy/de-interview-choose-what-the-source-must-retain/)A nightly product table shows $20 at both Monday and Tuesday close.
2. Part 2**Crash after the write**Current essayA worker writes dispatch D1, crashes before committing its input position, reprocesses D1, then receives genuine dispatch D2.
3. Part 3[Decide when yesterday can change](https://abundance.alloconomy.com/alloconomy/de-interview-decide-when-yesterday-can-change/)A dashboard must show dispatches within five minutes.

## The interview prompt

A worker writes dispatch D1, crashes before committing its input position, reprocesses D1, then receives genuine dispatch D2\. Design retries that leave six copies shipped and one customer notification per eligible dispatch.

## Draw the crash at three places

Before the destination write, retry must perform the write. After the write but before saving input progress, retry must recognize the same business occurrence and leave the destination unchanged. After progress is saved, the output must already be durable. Put those three checkpoints on the board and specify what is atomic at each one.

For a SQL destination, a unique (source, dispatch ID) can protect an insert. If a running total is updated separately, the unique insert and increment must commit or roll back together, and the increment must occur only for a newly accepted event. Deriving totals from the deduplicated fact table avoids that extra mutable state at the cost of additional reads. If the event source supports later corrections, make version handling explicit before treating duplicate IDs as final.

Sending a notification crosses a second boundary. Record an outbox item in the same transaction as the accepted event, then send it using a stable delivery key if the recipient API supports idempotency. A crash after successful delivery but before acknowledgment still leaves an ambiguous outcome without that recipient guarantee. State the delivery semantics you can actually offer.

## The model behind the answer

The worker adds four shipped units to Saturday’s total, then crashes before saving its input position. On restart, the same dispatch arrives again. A second increment would turn four physical books into eight reported books. Saving the position first simply moves the failure window to the other side of the write.

One design stores the dispatch under a stable unique event ID in the destination and derives totals from that table. Another atomically records the event ID and updates the aggregate in the same destination transaction. In either design, a retry has the same observable effect as one successful write. A separately maintained “seen IDs” cache needs its own consistency and retention story.

A **checkpoint** records recoverable progress and associated state. A **replay** rebuilds from retained input. To make an “exactly once” claim, name the destination included in the guarantee. If the job also sends a shipping email, that side effect needs its own deduplication agreement. [Apache Kafka on delivery semantics](https://kafka.apache.org/41/design/design/?ref=abundance.alloconomy.com)

## Try it in SQLite

Replay a dispatch and apply a correction

The inbox contains four messages for two occurrences. A retry repeats a version. A correction changes D2 from three to two copies. The corrected-total example assumes identical payloads for repeated versions. The conflict review introduces a producer violation. To challenge certification, insert another D2/version 2 row with 9 units and a new sequence number before the certification query. The fixture assumes non-null units and one source.

Tables and sample dataExample query Your SQL

Run SQLStopReset example

Each run starts with fresh sample data. Use Ctrl+Enter or ⌘+Enter to run. Only your browser processes the query.

Label Measure 

## Verify the effect outside the worker

Ask the agent for a retryable destination write and a notification outbox. The reviewer controls a fake recipient. Make it accept a notification, drop the acknowledgment, then restart the sender. Count actual accepted notifications at the recipient as well as rows in the outbox.

**Reviewer decision.** One outbox row can still produce two deliveries. With receiver-side deduplication on a stable key, two attempts should produce one accepted effect. Without that capability, record the ambiguous delivery and agree how to reconcile it. In the browser lab, try **Certify the replay total**. With matching retries it returns five corrected units. With conflicting quantities under D2 version 2 it withholds the total. The fake recipient tests a separate delivery guarantee.

*Further reading.* [Designing Data-Intensive Applications](https://www.amazon.com/dp/1098119061?ref=abundance.alloconomy.com), 2nd ed., on the boundary of checkpointing when output reaches an external system.

## One more question

You retained seen-event IDs for 24 hours but replay a month of input. What happens?

Check your reasoning

Older retries can be accepted again. Anchor deduplication in durable fact identities or retain state for the full replay horizon. Test a month-end backfill against a saved baseline, including a genuine source correction that should change the total.

1. [Back to the series openingPipelines that can recoverSeries 7 of 10](https://abundance.alloconomy.com/alloconomy/de-interview-choose-what-the-source-must-retain/)
2. [Explore the collectionThe Data Engineering Interview Field Guide](https://abundance.alloconomy.com/alloconomy/data-engineering-interview-field-guide/)

[Previous · Choose what the source must retain](https://abundance.alloconomy.com/alloconomy/de-interview-choose-what-the-source-must-retain/) · [Next · Decide when yesterday can change](https://abundance.alloconomy.com/alloconomy/de-interview-decide-when-yesterday-can-change/) · [Complete series map](https://abundance.alloconomy.com/alloconomy/data-engineering-interview-field-guide/)