Example DAG gets stuck in “running” state indefinitely

杀马特。学长 韩版系。学妹 提交于 2019-12-03 22:22:36
Ladislav Indra

To run any DAGs, you need to make sure two processes are running:

  • airflow webserver
  • airflow scheduler

If you only have airflow webserver running, the UI will show DAGs as running, but if you click on the DAG, none of it's tasks are actually running or scheduled, but rather in a Null state. What this means is that they are waiting to be picked up by airflow scheduler. If airflow scheduler is not running, you'll be stuck in this state forever, as the tasks are never picked up for execution.

Additionally, make sure that the toggle button in the DAGs view is switched to 'ON' for the particular DAG. Otherwise it will not get picked up by the scheduler if you trigger it manually.

I too recently started using Airflow and my dags kept endlessly running. Your dag may be set on 'pause' without you realizing it, and thus the scheduler will not schedule new task instances and when you trigger the dag it just looks like it is endlessly running.

There are a few solutions:

1) In the Airflow UI toggle the button left of the dag from 'Off' to 'On'. Off means that the dag is paused, so On will allow the scheduler to pick it up and complete the dag. (this fixed my initial issue)

2) In your airflow.cfg file dags_are_paused_at_creation = True, is the default. So all new dags you create are paused from the start. Change this to False, and future dags you create will be good to go right away (i had to reboot webserver and scheduler for changes to the airflow.cfg to be recognized)

3) use the command line $ airflow unpause [dag_id] documentation: https://airflow.apache.org/cli.html#unpause

The below worked for me.

  1. Make sure AIRFLOW_HOME is set
  2. in AIRFLOW_HOME have folders dags, plugins. The folders to have permissions r,w,x to airflow user.
  3. Make sure u have atleast one dag in the dags/ folder.
  4. pip install celery[redis]==4.1.1

I have checked the above soln on airflow 1.9.0 Airflow version

I tried the same trick with airflow 1.10 version and it worked.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!