🚀

Idempotent Data Pipelines

Building reliable, rerunnable data pipelines.

Section 1 of 2: What is Idempotency?0%

What is Idempotency?

Study Material

Idempotency means that running the same operation multiple times produces the same result as running it once.

Why Idempotency Matters in Data Engineering:

Data pipelines fail. Networks timeout. Servers crash. When you retry a failed job, will it:

  • ❌ Duplicate data?
  • ❌ Corrupt existing data?
  • ❌ Skip records?
  • ✅ Produce correct results?

Non-Idempotent (Dangerous):

INSERT INTO fact_sales (order_id, amount)

SELECT order_id, amount FROM staging;

Run twice → Duplicates!

Idempotent (Safe):

INSERT INTO fact_sales (order_id, amount)

SELECT order_id, amount FROM staging

ON CONFLICT (order_id) DO NOTHING;

Run twice → Same result!

Real-World Scenarios:

Scenario 1: Network Timeout

  • ETL job runs for 30 minutes
  • Completes successfully
  • But network times out before job reports success
  • Orchestrator thinks job failed, retries
  • Non-idempotent: Data duplicated
  • Idempotent: Safe to retry

Scenario 2: Partial Failure

  • Loading 1 million records
  • Fails at record 750,000
  • Need to restart
  • Non-idempotent: First 750K duplicated
  • Idempotent: Safely reprocess all

Scenario 3: Manual Rerun

  • Business user requests data fix
  • Developer reruns pipeline for date range
  • Non-idempotent: Data corruption risk
  • Idempotent: Safe to rerun anytime

The Golden Rule:

Every data pipeline should be safe to run multiple times. If it isn't, you will eventually have data quality issues.