liveBook · Manning

Failure

As explained in Data Pipelines with Apache Airflow, Second Edition

An error is a failure condition or abnormal event reported during system operation.

A data pipeline can fail even when its task code has not changed: an external service may be unavailable, a network connection may drop, or a disk may break. In Airflow, an unsuccessful task is marked failed. By default, downstream tasks require their preceding tasks to succeed, so a task blocked by a failure is marked upstream_failed rather than run. section 2.5

When a task fails, work from the affected run rather than restarting the whole workflow:

  • Find the failed task in the DAG’s graph or grid view. The grid also shows results across current and historical runs. section 1.2.4 section 2.5
  • Open its logs and inspect the stack trace for a likely cause. Fix the underlying problem before rerunning it. section 2.5
  • Clear the failed task instance to let Airflow run it again. When needed, select downstream tasks in the clear menu; previously successful tasks need not be restarted. section 2.5

Interrupted image download

A network interruption prevents an image-download task from connecting to its URL. The task fails, and its dependent notification task is marked upstream_failed. A ConnectionError in the download task’s logs points to the connection problem. After restoring connectivity, clear the failed task and the downstream work that should run afterward. section 2.5

Configure retries, optionally with waits between attempts, for intermittent task failures. If retries do not resolve the problem, Airflow records the failure and can send a notification when configured. Production monitoring should also track errors beyond individual DAG runs: examples include zombie tasks, timed-out tasks, and web-server responses other than HTTP 200. Errors are one of four monitoring signals alongside latency, load, and saturation. section 1.2.4 section 15.7.5

ConnectionError: Could not connect to https://thespacedevs-
➥prod.nyc3.digitaloceanspaces.com/media/images/
➥long_march_2_image_20210908195835.jpeg.

The ConnectionError illustrates the kind of concrete clue to look for in a failed task’s logs. section 2.5

How Data Pipelines with Apache Airflow, Second Edition covers it

How deep it goes
Walks through failure states, log inspection, retries, and targeted reruns; gives monitoring examples without specifying alert thresholds.
Examples
Uses a failed image download, its ConnectionError stack trace, and Airflow graph and grid views.
What it assumes
Assumes basic familiarity with DAG tasks and dependencies while explaining the failure and recovery steps through an example.
What you can do after
Diagnose/debug with it by finding a failed task, reading its logs, fixing the cause, and clearing affected tasks for rerun.
How it connects
Links failure to DAG dependencies, task states, retries, logs, and the monitoring signals latency, load, errors, and saturation.

Also explained in

Compare how 12 books explain failure →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Pipelines with Apache Airflow, Second Edition. The section links point to the parts of the book it draws on.