Airflow, Kestra and AWS orchestration all schedule and retry the steps of a data pipeline, but none of them makes a step safe to run twice. In healthcare pipelines that load claims, lab results or eligibility data, that safety is what lets a retry or a backfill fix a problem instead of creating a new one.
Startup founders and engineering leaders will find how each tool treats retries and backfills, how to write idempotent tasks and how to choose between them.
What is Airflow, Kestra and AWS orchestration?
Airflow, Kestra and AWS orchestration are three ways to schedule pipeline steps, track their state and rerun failures. Apache Airflow defines workflows in Python, Kestra in YAML, and AWS Step Functions as state machines. All three retry and replay runs, so every task must give the same result when it runs again.
Building or fixing a healthcare data pipeline?
We design pipelines that can retry and backfill without duplicating patient data.
The orchestrator decides when a task runs again. The task decides whether running again is harmless. Pipeline incidents often come from mixing up those two jobs, which is why Agnotic Technologies reviews task design before choosing a tool.
Why does idempotence matter in healthcare pipelines?
Idempotence matters because a pipeline that loads a day of lab results twice creates duplicate results in reports and quality measures, and duplicates in clinical data are slow to find and fix.
Apache Airflow's best practices say tasks should be treated like transactions in a database and produce the same outcome on every re-run. They advise replacing INSERT with UPSERT, never reading the latest available data in a task, and reading and writing a specific partition, such as one keyed by data_interval_start.
That advice holds whichever orchestrator you choose. A task should know exactly which slice of data it owns, and writing that slice again should replace it, not add to it.
How do you make a task idempotent?
You make a task idempotent by giving it a fixed input window, a deterministic output location and a write that replaces rather than appends.
- Step 1, window: pass the interval start and end into the task instead of reading the current time.
- Step 2, read: select source rows for that window only, from a snapshot or versioned extract where possible.
- Step 3, write: overwrite the partition for that window, or upsert on a business key such as claim ID and line number.
- Step 4, record: log the run's window, row counts and the orchestrator's run ID with the output.
- Step 5, verify: compare counts with the source before downstream tasks start.
Side effects outside the warehouse, such as sending a file to a payer or a message to an EHR interface, need their own guard: a sent-items table keyed by window and destination.
How do retries differ across Airflow, Kestra and AWS?
Retries differ in where they are configured and how waits grow, but each tool reruns the same task with the same inputs. That makes the task's design, not the retry setting, the deciding factor.
In AWS Step Functions, Task, Parallel and Map states can carry a Retry field of retriers matched by error name. A retrier waits IntervalSeconds before the first retry (1 by default), makes up to MaxAttempts retries (3 by default, and 0 means never retried) and multiplies the wait by BackoffRate (2.0 by default).
- Airflow: retries and the delay between them are set on each task or as DAG defaults.
- Kestra: a retry block on a task or a flow sets constant, exponential or random waits, and its maxAttempts counts the first run.
- Step Functions: retriers match named errors, so a timeout and a validation error can be treated differently.
- All three: a task that fails for a data reason will fail again, so do not retry what cannot succeed.
The counting difference is easy to miss when porting a pipeline. A setting that means three retries in one tool can mean two in another, so translate retry settings deliberately rather than copying numbers.
What does a backfill do?
A backfill runs a pipeline for past intervals, either because runs were missed or because the logic changed and old outputs need rebuilding. It is only safe when each interval's task replaces its own output.
Kestra defines backfills as replays of missed schedule intervals between a start and an end date, and warns that a backfill replays every interval in the window, including ones that already succeeded. Kestra recovers missed schedules automatically by default.
Airflow handles the same need differently. Its catchup setting is off by default, and a backfill is started by hand from the UI or CLI for a chosen date range. In both tools, a month of backfill means a month of tasks running again, each against its own window.
- Before: confirm the source still holds data for the window, since some feeds keep only recent days.
- During: limit concurrency so the backfill does not crowd out today's runs or overload the source.
- After: compare row counts per interval with the original run log.
- Always: tell report owners which periods changed.
Airflow, Kestra or Step Functions: which suits your team?
| Question | Apache Airflow | Kestra | AWS Step Functions |
|---|---|---|---|
| How workflows are written | Python DAG files | YAML flow definitions | State machine definitions |
| Who maintains them | Engineers comfortable with Python | Engineers and analysts who prefer declarative files | Teams already building on AWS services |
| Where it runs | Self-hosted, or managed through Amazon MWAA | Self-hosted by your team | Managed by AWS |
| Good fit | Many scheduled batch pipelines with shared Python code | Scheduled and event-triggered flows with a UI for less technical users | Pipelines made mostly of AWS service calls and Lambda functions |
There is no wrong answer among the three. A team already running Python data code may prefer Airflow; a team chaining AWS services may prefer Step Functions; a team that wants flows readable by analysts may prefer Kestra.
Keeping PHI safe in orchestration
Orchestrators store logs, parameters and sometimes task output, so they can hold patient data without anyone intending it. Treat the orchestrator as a system that contains PHI unless you prove otherwise.
- Parameters: pass windows and IDs, never patient names or record contents.
- Logs: keep row counts and keys in logs, not full records.
- Connections: store credentials in a secrets manager, not in workflow files.
- Access: limit who can trigger backfills, because a backfill can reload or overwrite clinical data.
Treat backfills like production changes. Record who started one, for which windows and why, so the audit trail explains any number that changed afterwards.
Monitoring runs and data together
Monitoring has to cover both the run and the data it produced. A green run that loaded zero rows is a failure the orchestrator will not report on its own.
- Alert on task failure, but also on runs that finish far later than usual.
- Check row counts per window against an expected range set with data owners.
- Flag windows where a backfill changed results, so report owners can review them.
- Keep a run history long enough to explain any number in a published report.
A worked example: a nightly lab results load
A worked example: a pipeline loads each day's lab results from a laboratory system's extract into a warehouse used for quality reporting.
- The run for one day receives that day's start and end as parameters and never reads the clock.
- The extract task pulls results for that window into a staging location named after the window.
- The load task rewrites the warehouse partition for that date inside one transaction, or upserts on result ID and version.
- A check task compares the loaded count with the extract count and fails the run if they differ.
- If the source corrects old results, a backfill over the affected dates rebuilds those partitions only.
A retry of any task in that run produces the same partition. A backfill months later rebuilds the partition as the corrected source now sees it, and the run log shows when it changed.
How should late and corrected data be handled?
Late and corrected data should be handled with a fixed look-back rule, because late arrivals and corrections are normal in healthcare feeds.
- Event time versus load time: partition by when the result was recorded, and keep the load time as a column.
- Look-back window: each run also reprocesses a few recent days to catch late records.
- Corrections: keep the latest version per business key, and keep history if reports need it.
- Cut-off: agree with report owners when a period is closed and later changes become an exception.
Dependencies between pipelines
Dependencies between pipelines decide whether a backfill upstream reaches the reports downstream. Make them explicit rather than relying on schedules lining up.
- Trigger downstream runs from upstream completion for the same window, not from a clock.
- When an upstream window is rebuilt, mark the matching downstream windows for rebuild too.
- Record which upstream run each downstream output used.
- Keep cross-tool dependencies simple while Airflow, Kestra and Step Functions run side by side during a migration.
What are the common mistakes with pipeline orchestration?
The common mistakes with Airflow, Kestra and AWS orchestration come from trusting retries to fix problems that only idempotent tasks can fix.
- Reading the current time: each rerun picks up a different window and outputs drift.
- Append-only writes: every retry adds a second copy of the same rows.
- Retrying data errors: a bad file is retried until the attempts run out, then fails anyway.
- Unbounded backfills: a long history runs at once and starves the source system.
- No run record: nobody can tell which run produced the numbers in a report.
What does orchestration mean for your build plan?
Plan pipelines around windows and keys first, then pick the orchestrator. Changing a task from append to replace after launch means rebuilding history.
- Define the interval and partition for every dataset.
- Name the business key for upserts in each target table.
- Write a retry policy per error type, including errors that are never retried.
- Agree who may run backfills and how report owners are told.
How does Agnotic build orchestrated pipelines?
Agnotic builds healthcare data pipelines on Airflow, Kestra or AWS Step Functions, with idempotent tasks, retry rules per error type, safe backfills and run records that tie every output to the run that produced it.
Pipelines you can rerun without fear
Idempotent tasks, clear retry rules and safe backfills for healthcare data.
Related reading on Agnotic
Data pipelines, orchestration and AWS reading.


