27 / 35 · The Data System
Orchestration and historical recomputation
Give a daily pipeline an explicit data interval, rerun an older day and publish its replacement without exposing partial results.
The sales report for 1 November shows 3200 cents for one store. On 5 November a correction adds 300 cents to the source data for that day. Running today’s scheduled job will not revisit 1 November. We need to name the interval, choose its source version and replace the report that readers see.
Give the run an interval#
An orchestrator starts work and records its dependencies and outcomes. The daily job can have four tasks. Extract prepares the input, validation checks it, aggregation totals it and publication exposes the result. Each task waits for the input it needs. The dependency graph is acyclic here because no task waits for its own output.
Use UTC and the half-open interval from 1 November at 00:00 to 2 November at 00:00. A sale at the right boundary belongs to 2 November. The original job might run at 00:10 on 2 November, and the repair can run on 5 November. Both target the same interval. Reading the system clock inside the extraction query would make the repair read the wrong day. In Airflow, a scheduled Dag run has a data interval distinct from when a worker actually starts. Manual runs need an explicit interval contract as well. Airflow, Dag Runs
Separate a retry from a backfill#
The original run used source snapshot S1. A retry after a temporary failure should keep the same input snapshot and transformation version if we want the same result. Repeating S1 gives 3200 cents again. A backfill materializes or recomputes historical partitions. In this case it explicitly uses snapshot S2, which contains the correction, and gives cents. Dagster makes historical partitions selectable for backfills. The transformation still needs to read the selected partition. Dagster, Backfilling data
One day, two input versions
Run identity and result identity have different jobs. A run ID distinguishes attempts for diagnostics. The result key here is the date and store. Appending S2’s output as another row would expose both totals. A consumer that summed them would read cents for one store and day.
Expose the replacement at one boundary#
Write and validate the candidate result before replacing the day. If the job fails while writing the candidate, readers still see the old version. When the candidate passes, commit the replacement as one operation. Iceberg publishes a table version through an atomic metadata change. A reader using the prior snapshot keeps its prior view until it refreshes. Apache Iceberg, Optimistic Concurrency
An atomic commit alone does not choose the correct version. If a late retry based on S1 can replace a published S2, the pipeline can move backwards. Before publication check that the target partition is still at the expected version. On conflict, decide whether the candidate is obsolete or must be recomputed. A multi-day backfill can also compete for compute and I/O with today’s scheduled work. Bound the number of concurrent historical intervals and track which intervals have actually been replaced.
Next#
The publication step assumes we can decide whether a candidate passes. Data contracts and quality separates checks a parser can perform from checks about the meaning and completeness of a day’s data.
References#
- Apache Airflow. Dag Runs. Data Interval and Backfill distinguish intervals from execution time and define rerun scope.
- Dagster. Backfilling data. Describes recomputing selected historical asset partitions.
- Apache Iceberg. Table Specification, Optimistic Concurrency. Specifies snapshot visibility and atomic metadata replacement.