You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/04/04 03:10:09 UTC

[GitHub] [airflow] imsharadmishra removed a comment on issue #9975: max_active_runs = 1 can still create multiple active execution runs

imsharadmishra removed a comment on issue #9975:
URL: https://github.com/apache/airflow/issues/9975#issuecomment-812917371


   I had the same issue with airflow 2.0.1. 
   I was able to fix it following combinations of parameter.
   AIRFLOW__CORE__MAX_ACTIVE_RUNS_PER_DAG -> 16 (default value)
   max_active_runs=1 inside the dag.
   Trick here I used it to pass this parameter inside DAG constructor instead of default_args argument.
   
   Here is an example:
   
   ```from airflow import DAG
   from airflow.providers.mysql.operators.mysql import MySqlOperator
   from airflow.utils.dates import days_ago
   from airflow.sensors.sql_sensor import SqlSensor
   from airflow.operators.bash import BashOperator
   from datetime import datetime, timedelta
   from airflow.hooks.base_hook import BaseHook
   from airflow.contrib.operators.slack_webhook_operator import SlackWebhookOperator
   
   
   default_args = {
       'owner': 'airflow',
       'start_date': datetime(2021, 3, 31, 14, 00)
   }
   
   dag = DAG(
       'example_sensor',
       default_args=default_args,
       tags=['mysql', 'sensor'],
       schedule_interval='*/3 * * * *',
       catchup=False,
       max_active_runs=1
   )
   
   check_slices_sql_sensor_task = SqlSensor(
       task_id='check_slices', 
       conn_id='mysql_novus', 
       sql=r"""SELECT * FROM slices;""", 
       poke_interval=30, timeout=60,
       dag=dag
   )
   
   
   
   print_slices = BashOperator(
       task_id='print_slices',
       bash_command='sleep 480',
       dag=dag
   )
   check_slices_sql_sensor_task >> print_slices
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org