Introducing a new way to review your PRs.

Read the announcement

dagster-io / dagster

An orchestration platform for the development, production, and observation of data assets.

View on GitHub

19 documents · Updated Nov 23, 2026

docs / run-planning-and-execution

Run planning and execution

A run moves from a stored request to an ordered set of steps and then to a stream of step and run events. Planning turns job structure, run configuration, and selection into executable work. Orchestration then schedules that work, records its results, and turns errors or interrupts into clear run outcomes.

This page describes the execution lifecycle. See Execution runtime for the wider runtime model, Instance and persistence for stored run and event data, Resources and I/O managers for data and resource lifecycles, and Events and observability for event and log use.

Run submission

Run records

A run record is the durable request for one job execution. It carries the job identity, run configuration, selection, tags, run-group links, and optional plan snapshot that later workers need to reproduce the work.

The normal creation path stores a run in NOT_STARTED. A queue coordinator can change that request to QUEUED, while a launcher hands it to a run worker. A run group links a reexecution to its parent and root run so the system can track related attempts.

References: python_modules/…/dagster_run.py• L53-123 python_modules/…/dagster_run.py• L236-287 python_modules/…/run_domain.py• L86-107 python_modules/…/run_domain.py• L236-263

Launch handoff

The handoff separates run control from run work. The queue accepts a new run and the run launcher starts a worker for it; the worker later reconstructs the job and executes the plan for the stored run.

Cancellation follows the same boundary. A queued run can be marked canceled without starting a worker. A launched run enters CANCELING and receives a termination request through the launcher.

References: python_modules/…/queued_run_coordinator.py• L308-341 python_modules/…/default_run_launcher.py• L98-126 python_modules/…/default_run_launcher.py• L153-184

Asset backfill scheduling

An asset backfill is a long-running batch process that turns a target set of asset partitions into run requests over repeated daemon iterations. It records which targets are requested, materialized, or failed so later iterations can request only eligible work and so the backfill can reach a final result.

The first iteration requests root assets in the target graph. Later iterations read new materializations and failed runs, then use asset dependencies and partition mappings to decide which downstream partitions can join new runs. For a ranged run that materializes some partitions and fails on others, the full planned range is treated as failed work first; materialized partitions are then removed from that set. This records only the unmaterialized partitions as failed on the same iteration. Run requests are stored before submission and submitted in chunks. This gives cancellation and restart handling a durable point from which to continue.

The backfill waits for active runs and pending automatic retries before it declares completion. If all runs finish but a targeted partition has no materialization or failure state, the backfill marks that remaining work as failed instead of staying in progress forever.

The following flow shows how a target asset set becomes a sequence of runs and a backfill result.

flowchart LR
    A[Target asset partitions] --> B[Root and eligible partitions]
    B --> C[Run requests]
    C --> D[Submitted backfill runs]
    D --> E[Materializations and failures]
    E --> F{Targets have final status?}
    F -->|no| B
    F -->|yes| G[Backfill success or failure]

References: python_modules/…/asset_backfill.py• L1022-1173 python_modules/…/asset_backfill.py• L1352-1434 python_modules/…/asset_backfill.py• L1604-1746 python_modules/…/asset_backfill.py• L2202-2266

Execution planning

Plan construction

Planning resolves the run configuration and converts the job graph into an execution plan. The plan represents executable steps, their input sources, their outputs, and the dependency rules that control when each step may run.

Input sources can be run configuration, a prior step output, an asset, or an input manager. The plan also records which resources those sources need. A selected subset limits the work to requested steps, while dynamic mappings remain as placeholders until an upstream step produces its mapping keys.

The plan records the selected execution engine and can form a smaller plan for a requested step set. This keeps selection and dependency handling in the plan that the executor receives.

References: python_modules/…/api.py• L651-718 python_modules/…/plan.py• L92-212 python_modules/…/plan.py• L214-370 python_modules/…/inputs.py• L70-89 python_modules/…/inputs.py• L345-369

Plan snapshots

A plan snapshot preserves the plan shape and the state needed to run it again. When a run has a snapshot, the worker can rebuild the plan from the stored record instead of depending only on the current in-memory job definition.

The run stores the snapshot identity beside the job snapshot. Reexecution uses the parent run's event history and snapshot to select work that needs to run and to reuse outputs or dynamic mappings that are already known.

References: python_modules/…/api.py• L651-674 python_modules/…/run_domain.py• L295-355 python_modules/…/state.py• L101-188

Step orchestration

Active execution

ActiveExecution is the plan state machine used by executors. It tracks pending, ready, in-flight, successful, failed, skipped, abandoned, and retrying steps while also tracking produced outputs.

The orchestrator asks this state machine for work. A step becomes ready when its dependency rule is satisfied and its required outputs are available. A failed or skipped upstream step can cause downstream work to skip or become abandoned. A dynamic output can add new concrete steps after its mapping keys resolve.

The following flow shows how a planned run becomes step work and then a run result.

flowchart LR
    A[Stored run] --> B[Resolved run configuration]
    B --> C[Execution plan]
    C --> D[Active execution]
    D --> E{Dependencies and limits}
    E -->|ready| F[Executor starts step]
    E -->|blocked| E
    F --> G[Step events and outputs]
    G --> D
    D --> H[Run success, failure, or cancellation]

The state machine can wait for all upstream steps to resolve or use a mode that starts work when all required upstream outputs exist. If a step ends without a terminal event, it becomes an unknown state and its downstream work is abandoned.

References: python_modules/…/active.py• L52-129 python_modules/…/active.py• L296-367 python_modules/…/active.py• L388-452 python_modules/…/active.py• L579-642

Concurrency control

Readiness does not always mean immediate execution. The state machine applies per-run limits, tag limits, and shared pool claims before it marks a step in flight.

When a step waits for a shared slot, the run stays active and emits blocked-step information. The same state also releases a claim when a step succeeds, fails, or moves to retry, which lets later work proceed.

References: python_modules/…/active.py• L405-452 python_modules/…/active.py• L579-625 python_modules/…/active.py• L723-742

Executor behavior

Executor contract

An executor owns the way a complete execution plan is scheduled. Its contract is to consume the plan and orchestration context, then yield the events that describe step work and its result.

The executor supplies retry behavior and step dependency rules to plan orchestration. Context setup creates the configured executor before plan execution begins. If executor or logger setup fails, the run receives a job initialization failure rather than starting step work.

References: python_modules/…/base.py• L19-49 python_modules/…/context_creation_job.py• L304-370 python_modules/…/context_creation_job.py• L421-431

Execution contexts

An execution context joins the run, resolved configuration, plan, logs, resources, and retry state that a step needs. The runtime prepares this context before work starts and tears down resources after the plan ends.

Only resources required by the plan are initialized. Resource dependencies are checked and initialized in dependency order. Resource setup and teardown produce events, so a resource failure can stop execution before compute begins.

References: python_modules/…/context_creation_job.py• L96-145 python_modules/…/context_creation_job.py• L179-255 python_modules/…/resources_init.py• L67-116 python_modules/…/resources_init.py• L119-213 python_modules/…/init.py• L34-101

Execution modes

The runtime supports execution in one process, across child processes, or through a step handler that starts work in another environment. These modes share the same plan state and event model, so the product behavior stays consistent while the placement of compute changes.

The main differences are the boundary at which work runs and how the parent learns that work finished:

ModeWork placementResult path
In-processThe run worker executes steps in its own process.The worker consumes step events directly.
MultiprocessThe parent starts child processes for steps.Child events return to the parent, which updates plan state.
Step-delegatingA step handler starts and monitors external step workers.The executor reads step events from the run event log and checks worker health.

An external step worker receives a step run reference. The reference carries enough run, job, retry, selection, and known-state information to rebuild a one-step plan in the worker. The worker sends its events back to the host instance, where the normal orchestration state consumes them.

References: python_modules/…/in_process.py• L20-32 python_modules/…/in_process.py• L56-93 python_modules/…/multiprocess.py• L161-217 python_modules/…/multiprocess.py• L242-329 python_modules/…/step_delegating_executor.py• L34-39 python_modules/…/external_step.py• L107-158 python_modules/…/external_step.py• L182-254

Step execution

Step event sequence

Step execution turns inputs into outputs and records the checks around that work. The step context loads inputs through configuration, upstream outputs, assets, or input managers. It checks input values, calls user compute, checks outputs, and emits success or failure events.

The event stream is the shared contract between local work and remote work. It carries output handles for downstream dependency checks and carries enough error data for the plan state machine to decide whether to continue, skip, abandon, or retry.

References: python_modules/…/execute_step.py• L438-507 python_modules/…/inputs.py• L108-180 python_modules/…/inputs.py• L345-369 python_modules/…/execute_step.py• L322-435

Output validation

Output validation keeps the declared step contract aligned with the values emitted by compute. The runtime rejects unknown or unselected outputs, duplicate outputs, invalid dynamic output use, missing required outputs, and failed type checks before it treats the output as available to downstream work.

Output context also carries the run and step identity, asset and partition identity, mapping key, metadata, type, and resources used to store the value. This lets an I/O manager store the result with the same execution and asset meaning that the plan uses.

References: python_modules/…/execute_step.py• L168-306 python_modules/…/execute_step.py• L386-435 python_modules/…/output.py• L66-174 python_modules/…/output.py• L194-348

Asset data versions

Asset data version tracking links a step's inputs to the latest materialization or observation of each upstream asset. For partitioned inputs, the runtime can combine the versions of the selected partitions into one input version used for provenance and stale-data checks.

The cache keeps this information during the step and refreshes it when a step creates a newer related asset. A mismatch between an in-step value and the latest stored event favors the latest stored event for provenance.

References: python_modules/…/data_version_cache.py• L35-93 python_modules/…/data_version_cache.py• L95-139 python_modules/…/data_version_cache.py• L176-210 python_modules/…/execute_step.py• L438-462

Step failures

The step boundary classifies errors so that user failures, framework errors, interrupts, and retry requests do not look the same. A normal user failure produces a step failure event. An interrupt is re-raised so the run-level layer can decide whether it means cancellation or an unexpected termination.

Hooks run after a step's events are collected. A hook error produces a hook error event and does not by itself turn the run into a step failure.

References: python_modules/…/execute_plan.py• L127-171 python_modules/…/execute_plan.py• L184-243 python_modules/…/execute_plan.py• L245-342

Retry and reexecution

Step retries

Step retry policy controls whether failed step work is attempted again inside the current run. An enabled executor places the step back into the plan after its delay. A deferred mode records the retry request for the outer orchestrator instead of launching the step again inside the inner plan.

Retries stop when the policy limit is reached or when retries are disabled. Known execution state carries attempt counts across process boundaries, along with resolved dynamic mappings and ready outputs, so a child worker and its parent apply the same retry view.

References: python_modules/…/retries.py• L30-62 python_modules/…/execute_plan.py• L245-292 python_modules/…/active.py• L550-570 python_modules/…/state.py• L101-167

Run reexecution

Run reexecution creates a new run linked to a parent run. A retry from failure derives completed outputs, dynamic mappings, skipped steps, failed steps, and interrupted steps from the parent event log. The new plan can then run only the work that needs another attempt.

The derived known state includes the parent plan's output and dynamic mapping facts. It also preserves the distinction between work that was skipped, work that failed, and work that stopped without a terminal event. Automatic run retry is separate from an in-run step retry. It applies to a failed run when the configured retry count allows another run and when the failure reason and retry settings permit it.

References: python_modules/…/api.py• L508-582 python_modules/…/state.py• L169-188 python_modules/…/state.py• L225-345 python_modules/…/retries.py• L83-152

Run status transitions

Status events

Run status is the coarse result of the event stream. Run events map to durable statuses, while step events explain the work that led to that status.

The normal lifecycle is NOT_STARTED or QUEUED, then STARTING, then STARTED, and finally SUCCESS or FAILURE. A termination request moves an active run through CANCELING to CANCELED. MANAGED identifies a run whose execution is controlled outside the normal control plane.

stateDiagram-v2
    [*] --> NOT_STARTED
    NOT_STARTED --> QUEUED
    NOT_STARTED --> STARTING
    QUEUED --> STARTING
    STARTING --> STARTED
    STARTED --> SUCCESS
    STARTED --> FAILURE
    STARTED --> CANCELING
    CANCELING --> CANCELED
    QUEUED --> CANCELING
    CANCELING --> FAILURE

References: python_modules/…/dagster_run.py• L53-123 python_modules/…/__init__.py• L262-272 python_modules/…/api.py• L721-835

Completion handling

The run-level iterator gathers step failures while the executor runs. At completion it emits success when all work finishes cleanly, failure when a step or execution error remains, or cancellation when termination controls the outcome.

The worker reloads the run after execution so the returned result reflects status changes recorded during the event stream. A worker that starts after a finished run is ignored, while an unexpected restart is either ignored under run monitoring or marked as a run failure.

References: python_modules/…/api.py• L55-114 python_modules/…/api.py• L168-266 python_modules/…/api.py• L721-835

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to run status event names must stay aligned with EVENT_TYPE_TO_PIPELINE_RUN_STATUS and with the event storage path that updates the run record.
  • Changes to plan snapshot fields must preserve the data needed by ExecutionPlan.rebuild_from_snapshot and by KnownExecutionState during reexecution.
  • Changes to retry mode must preserve the outer-executor and inner-plan split. Otherwise one retry request can be launched twice or not launched at all.
  • Changes to step event shape must remain usable by in-process, multiprocess, and step-delegating executors because all three update plan state from those events.
  • Changes to run-group or parent-run rules must preserve both manual and automatic retry counting.
  • Changes to input sources or output context fields must keep input managers, I/O managers, asset partitions, and external step workers able to reconstruct the same value identity.
  • Changes to resource dependency or initialization rules must preserve the required-resource set computed from the plan and the setup/teardown event contract.
  • Changes to data-version lookup must preserve the link between partition mappings, latest asset events, and provenance for outputs created in the same step.
  • Changes to external step references must preserve run selection, retry state, repository load data, and event return to the host instance.
  • Changes to asset backfill bookkeeping must preserve root-first dependency gating and the distinction between requested, materialized, and failed partitions. Failed partitions from a ranged run must be derived from the full planned range and then reduced by materializations.
  • Changes to backfill event cursors or completion checks must keep late materializations and runs waiting for automatic retry from being missed.
  • Changes to backfill submission must preserve the persisted in-flight request set so interruption, cancellation, and restart do not submit the wrong runs.

Important failure modes

TriggerConsequenceGuard
A run worker starts after the run already finished.The duplicate worker can produce conflicting work.The execution entry point ignores the worker for a finished run.
A required input or output is missing or has the wrong type.The step fails before downstream work can use the value.Plan sources and step checks require declared inputs, valid types, and non-optional outputs.
A step emits a retry request with retries disabled or after the limit.The retry becomes a step failure.Retry mode and attempt count are checked before a retry event is emitted.
A child or external step worker stops without a terminal event.The step enters an unknown state and downstream work does not run.Executors verify completion and treat unknown state as an execution error.
A run is interrupted without a termination request and cannot resume.The run is treated as an unexpected termination and fails.Run completion checks cancellation state and resume intent before choosing the final event.
The execution plan cannot initialize its executor, logger, or required resource.No step starts and the run fails during job initialization.Context creation and resource setup emit initialization failure events.
An input manager or I/O manager cannot load or store the value described by its context.The step cannot pass data across a dependency boundary.Input and output contexts carry the matching manager, asset, partition, type, and run identity.
Asset version records are missing or conflict with a value created in the current step.Provenance or stale-data results can use the wrong upstream version.The data version cache checks the latest materialization or observation and refreshes changed asset records.
An asset or its target partition changes after an asset backfill is stored.The backfill cannot safely map its saved targets to the current asset graph.Backfill validation fails the load or pauses processing when the affected code location is unavailable.
A ranged backfill run materializes some target partitions and fails on others.The unmaterialized partitions can remain in progress if failure detection treats the whole asset as successful.The full planned range is used as the failure candidate, then known materializations are removed.
Backfill runs finish without a materialization or failure state for a target.The backfill could remain in progress forever.The iteration detects a stall and marks the unresolved target partitions as failed.
A backfill is canceled while its run requests are being submitted.Extra runs can start after cancellation or progress can be lost.Submission persists requests in chunks and checks the backfill status between chunks.

Key files

FileWhy to read it
python_modules/…/api.pyMain entry points for run execution, plan creation, reexecution, and final run events.
python_modules/…/plan.pyShows how job structure, configuration, input sources, and selection become a dependency-aware execution plan.
python_modules/…/active.pyDefines the state machine that selects, tracks, retries, skips, abandons, and validates steps.
python_modules/…/execute_plan.pyConnects the plan to the executor and classifies step and plan errors.
python_modules/…/execute_step.pyDescribes the input, compute, output validation, asset event, and step event lifecycle.
python_modules/…/inputs.pyShows how configuration, assets, upstream outputs, and input managers supply step inputs.
python_modules/…/external_step.pyIllustrates how a single step is reconstructed and run outside the plan process.
python_modules/…/context_creation_job.pyShows how run context, resources, logs, and the configured executor are prepared and closed.
python_modules/…/resources_init.pyDefines resource dependency checks, initialization order, and resource lifecycle events.
python_modules/…/output.pyDefines the context contract used when an output is stored or associated with an asset.
python_modules/…/data_version_cache.pyShows how upstream asset versions support step-level provenance.
python_modules/…/base.pyDefines the shared executor contract and retry decision helpers.
python_modules/…/multiprocess.pyIllustrates parent orchestration and child-process step execution.
python_modules/…/step_delegating_executor.pyIllustrates event-log tailing and health checks for external step workers.
python_modules/…/dagster_run.pyDefines the run record and the run status model.
python_modules/…/state.pyDefines the state carried into retries, delegated steps, and reexecution.