Area: Ingestion Issues
Sub-Area: Airflow Plugin Configuration and Stability
Applies to: OSS + Cloud
Issue
The DataHub Airflow plugin is installed. GMS (the DataHub metadata service) is slow or briefly unavailable. During that time the Airflow scheduler slows down, misses heartbeats, or gets restarted by Kubernetes as unhealthy.
The scheduler log shows this plugin warning:
Thread for on_dag_run_running is still running after 10.0 seconds. Continuing without waiting for it to finish.
Task logs can show the same warning for on_task_instance_running, on_task_instance_success or on_task_instance_failed, along with read timeout errors from the DataHub emitter.
You Might Be Asking
- Why does the scheduler wait on DataHub at all?
- Is it safe to set
DATAHUB_AIRFLOW_PLUGIN_RUN_IN_THREAD_TIMEOUT=0, and where? - Does
ASYNCemit mode stop the scheduler from waiting? - Which plugin version should I run?
Cause
The plugin runs each listener hook (DAG run running, task running, task success, task failed) in its own background thread. The calling process then waits for that thread for up to DATAHUB_AIRFLOW_PLUGIN_RUN_IN_THREAD_TIMEOUT seconds. The default is 10 seconds. If the thread is still running after that, the plugin logs the warning above and moves on. The thread keeps running in the background.
The scheduler handles DAG run events. So when GMS is slow, every DAG run that starts can hold the scheduler for up to 10 seconds. With many DAG runs starting at once, those waits add up and the scheduler misses heartbeats.
The scheduler waits at most the run-in-thread timeout per event. It does not wait for the full HTTP read timeout plus retries. Those only control how long the background thread keeps trying. By default the emitter uses a 30 second timeout and retries a failed request up to 4 times, POST included.
Emit mode does not change this wait. In ASYNC mode, GMS accepts the write and returns before it commits to the database. That shortens each request when GMS is up but slow to commit. It does nothing when GMS cannot respond at all. The plugin still sends a normal HTTP POST to /aspects?action=ingestProposal and waits for the reply.
Solution
-
Stop the scheduler from waiting. Set this environment variable on the Airflow scheduler only, then restart the scheduler:
DATAHUB_AIRFLOW_PLUGIN_RUN_IN_THREAD_TIMEOUT=0With
0, the plugin starts the thread and returns right away. This is the fix the Airflow plugin docs give for scheduler stalling. The thread is a daemon thread. If the process exits before the thread finishes, the thread is killed and that metadata is not sent. A scheduler runs for a long time, so this rarely happens there. Task processes exit as soon as the task ends, so do not set0on workers. Keep the default there. -
Shorten how long each background emit keeps trying. Each event starts its own thread, so shorter timeouts mean fewer threads waiting on GMS at the same time. In the Airflow UI, go to Admin > Connections, edit your DataHub connection (default
datahub_rest_default), and put this in the Extra field:{ "retry_max_times": 1, "read_timeout_sec": 10, "connect_timeout_sec": 5 }The plugin passes these keys to the DataHub REST emitter.
-
Use
ASYNCemit mode. How you set it depends on your Airflow version.On Airflow 3, upgrade
acryl-datahub-airflow-pluginto the latest release. Since plugin 1.6.0.9,ASYNCis the default. It is set byemit_modeunder[datahub]inairflow.cfg(see Optional Configurations). The plugin passes this value to its emitter, so theDATAHUB_EMIT_MODEenvironment variable has no effect on the plugin's writes. Only setemit_modeif you want a mode other thanASYNC.pip install --upgrade acryl-datahub-airflow-pluginOn Airflow 2, DataHub no longer supports Airflow 2.x, and plugin fixes ship only for Airflow 3. Plugin 1.6.0.1 and later require Airflow 3.0 or later. Plugin 1.6.0 is the last release that runs on Airflow 2.7 through 2.10 (see Compatibility). That plugin has no
emit_modeoption, and its default emit mode is synchronous. Set this environment variable on the scheduler and the workers to switch toASYNC:DATAHUB_EMIT_MODE=ASYNCPlan an upgrade to Airflow 3 to get current plugin releases.
-
If GMS itself is slow to accept writes, the steps above protect Airflow but do not fix GMS. DataHub Cloud customers should contact DataHub Support. Self-hosted users should check GMS health and its database during the slow periods.
How to Verify
- After step 1, the scheduler log no longer shows
Thread for on_dag_run_running is still running after 10.0 secondsduring GMS slowdowns, and scheduler heartbeats stay steady. - DAG and task run data still shows up in DataHub after GMS recovers for runs whose emit threads finished.