Area: Ingestion Issues
Sub-Area: Airflow Plugin Configuration
Applies to: OSS + Cloud
Issue
You use the DataHub Airflow plugin. Your DAGs, tasks and lineage show in DataHub. But on the Runs tab of an Airflow task, runs stay in the Running status after the Airflow task finished. Success and failure results do not show. If no run reached DataHub at all, the Runs tab is disabled.
Your Airflow workers have the environment variable DATAHUB_AIRFLOW_PLUGIN_RUN_IN_THREAD_TIMEOUT set to 0.
You Might Be Asking
- Why do my Airflow task runs stay in Running in DataHub when the task already finished?
- Why do I see my DAGs and lineage in DataHub, but no completed runs?
- Can I set
DATAHUB_AIRFLOW_PLUGIN_RUN_IN_THREAD_TIMEOUTinairflow.cfg? - I set this variable to
0to stop scheduler stalling. Do I need to remove it?
Cause
The plugin sends metadata to DataHub from a background thread. It does this when a task starts, succeeds or fails. DATAHUB_AIRFLOW_PLUGIN_RUN_IN_THREAD_TIMEOUT sets how many seconds the plugin waits for that thread to finish. The default is 10.
When the value is 0, the plugin starts the thread and does not wait for it. The thread stops when the process that started it exits.
A process that runs a task exits when the task ends. With 0, it often exits before the thread sends the success or failure event. The start event usually gets through, because the thread has time to finish while the task runs. That start event carries the DAG, the task, its lineage and the run in the Running state. So DataHub shows the run as Running and never gets the result.
The plugin reads this setting only from the process environment. It is not an airflow.cfg option. A DATAHUB_AIRFLOW_PLUGIN_RUN_IN_THREAD_TIMEOUT line under [datahub] in airflow.cfg has no effect.
Solution
-
Find where your Airflow deployment sets environment variables for its workers. Examples are the deployment environment variables in Astronomer or Cloud Composer, or the container
envin a Kubernetes deployment. -
On the workers, remove
DATAHUB_AIRFLOW_PLUGIN_RUN_IN_THREAD_TIMEOUT. The plugin then uses the default of10seconds. You can also set it to a positive number of seconds:DATAHUB_AIRFLOW_PLUGIN_RUN_IN_THREAD_TIMEOUT=10 -
If you set
0on the scheduler to stop scheduler stalling, you can keep it there. The scheduler is a long-running process, so the background thread finishes. This is the fix that Airflow Integration: Scheduler stalling describes. The docs note that the plugin can miss some metadata if the scheduler shuts down soon after it processes a task. -
If you added
DATAHUB_AIRFLOW_PLUGIN_RUN_IN_THREAD_TIMEOUTtoairflow.cfg, remove that line. It does nothing there. -
Restart the Airflow workers, and the scheduler if you changed it.
-
Run a DAG. In DataHub, open one of its tasks and go to the Runs tab. Check that the new run shows a success or failure result.
DataHub no longer supports Airflow 2.x. Plugin fixes ship only for Airflow 3. See Airflow Integration: Compatibility.
Related Documentation
- Airflow Integration
- Airflow Integration: Scheduler stalling
- Airflow Integration: Optional Configurations
- Airflow Integration: Compatibility
- DataHub Airflow Plugin: Configuration
Tags: airflow, airflow-plugin, run-history, missing-runs, DATAHUB_AIRFLOW_PLUGIN_RUN_IN_THREAD_TIMEOUT, timeout, configuration, scheduler-stalling, ingestion