Why does the ExternalTaskSensor get stuck?
If you configured an ExternalTaskSensor in Airflow to wait until a task in another DAG finishes (or the entire DAG finishes), you have probably noticed that it behaves surprisingly. Most data engineers assume that it is a bug, and their sensor gets stuck for whatever reason. I have to admit that I find it annoying because the documentation of the ExternalTaskSensor does not warn us about it.
ExternalTaskSensor works only if the other DAG has the same execution date equal to the expected execution date. Sure, you can specify the execution time delta, but it is not a time range.
- The execution date of the DAG that contains the sensor is: 2020-10-01 14:00:00
- The execution delta = 3 hours
In this situation, the other DAG’s execution date must be 2020-10-01 11:00:00.
I think that most data engineers expect that delta = 3 hours means that the other DAG may execute at any time between 11:00 and 14:00.
Did you enjoy reading this article?
Would you like to learn more about leveraging AI to drive growth and innovation, software craft in data engineering, and MLOps?
Subscribe to the newsletter or add this blog to your RSS reader (does anyone still use them?) to get a notification when I publish a new essay!
You may also like
- How to use Airflow backfill to run DAGs for a specified date in the past?
- How to use xcom_pull to get a variable from another DAG
- Pass parameters to SQL query when using PostgresOperator in Airflow
- How to use Virtualenv to prepare a separate environment for Python function running in Airflow
- How to render an Airflow template for testing
- MLOps engineer by day
- AI and data engineering consultant by night
- Python and data engineering trainer
- Conference speaker
- Contributed a chapter to the book "97 Things Every Data Engineer Should Know"
- Twitter: @mikulskibartosz
- Mastodon: @email@example.com