Skip to content
Blog

Engineering

Designing Idempotent Workers for Data Pipelines

Practical patterns for safer ingestion, retries, and medallion-style processing on AWS.

June 20, 2026 / 3 min read
Data EngineeringWorkersReliability
Phan Hoang Nguyen ยท Backend Engineer

Retries are a fact of life in data pipelines โ€” a worker crashes mid-batch, a scheduler fires twice, an upstream export gets replayed. The question isn't whether your ingestion worker runs more than once, it's whether running it twice quietly corrupts your data. Idempotent workers make "run again" a safe, boring operation. ๐Ÿ”

Treat ingestion as a repeatable operation

A worker is idempotent when processing the same input twice leaves the system in the same state as processing it once. In AWS Glue and AppFlow pipelines, that means making three things explicit:

  • Source identity โ€” a stable key for every input (object key + version, or an event ID), so you can recognize a replay.
  • Target partitioning โ€” deterministic output locations, so a re-run overwrites the same partition instead of appending a duplicate.
  • Transformation state โ€” checkpoints or markers that record what's already been processed.

Get those right and a duplicate run is a no-op, not an incident.

Make the write deterministic

The most reliable idempotency technique is to let the destination reject duplicates, rather than trusting the worker to remember. A few patterns, roughly in order of strength:

TechniqueHow it worksBest for
Deterministic partition overwriteRe-run rewrites the same dt=/id= partitionBatch loads to S3 / lakehouse
Idempotency key + conditional writePUT if not exists on a natural keyRow-level upserts
Dedup tableRecord processed IDs, skip on repeatEvent-by-event consumers

Here's the shape of a single run:

mermaid
flowchart TD
    A[Worker picks up batch] --> B{Seen this<br/>source ID?}
    B -->|Yes| C[Skip ยท no-op]
    B -->|No| D[Transform]
    D --> E[Write to deterministic<br/>partition / key]
    E --> F[Record source ID<br/>as processed]

Design around medallion layers

Bronze, Silver, and Gold layers give idempotency a natural home. Raw input lands in Bronze exactly as received โ€” replays here are cheap because Bronze is append-and-dedup, not business logic. Silver applies validated transforms against Bronze, so re-running a transform is deterministic by construction. Gold serves the curated shape analytics consume, insulated from operational side effects upstream. Because each layer only reads the one below it, re-processing any layer is safe as long as its write is deterministic.

Build governance and observability into the path

Reliability includes knowing when a retry misbehaved. Lake Formation, IAM roles, and SSO keep access decisions close to the pipeline, while CloudWatch, CloudTrail, and Macie surface the signals that catch a bad replay: sudden row-count jumps, duplicate natural keys, or a partition that grew when it should have been overwritten. Idempotency you can't observe is idempotency you're only hoping for.

Keep reading