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 2022/07/11 17:44:21 UTC

[GitHub] [airflow] karunpoudel-chr opened a new issue, #24973: increasing ti.max_tries doesn't add more retries

karunpoudel-chr opened a new issue, #24973:
URL: https://github.com/apache/airflow/issues/24973

   ### Apache Airflow version
   
   2.2.5
   
   ### What happened
   
   A task (PythonOperator) had `'retries': 1`. When the task runs, depending upon conditions, it dynamically increases it's max_tries by using `kwargs['ti'].max_tries += 1` and the task fails. Airflow only retried once based on what was set in the Operator. It did retry more than once as it should have based on new ti.max_tries.
   This was working in 2.1.4 but stopped working after 2.2.0.
   
   ### What you think should happen instead
   
   Airflow should have retried the task 2nd time also since the new ti.max_tries is 2.
   This was working in 2.1.4 but stopped working after 2.2.0.
   
   ### How to reproduce
   
   The following dag retries only once, whereas in 2.1.4 it retires 4 more times.
   
   ```
   from datetime import timedelta
   import pendulum
   from airflow import DAG
   from airflow.operators.python import PythonOperator
   
   default_args = {
       'owner': 'airflow',
       'depends_on_past': False,
       'email_on_failure': True,
       'email_on_retry': False,
       'retries': 1,
       'retry_delay': timedelta(seconds=10),
   }
   
   
   def main(**kwargs):
       print("hello")
       try_number = kwargs['ti'].try_number
       print(f"Try = {try_number}")
       some_condition = True
       if some_condition and try_number <= 4:
           print(f"Max = {kwargs['ti'].max_tries}")
           print('Increasing max_tries by 1')
           kwargs['ti'].max_tries += 1
           raise Exception("Retry again")
   
   
   with DAG('test_retry',
            start_date=pendulum.datetime(2021, 1, 1, tz='America/Chicago'),
            max_active_runs=1,
            schedule_interval=None,
            default_args=default_args,
            catchup=False
            ) as dag:
   
       test_retry= PythonOperator(
           task_id="test_retry",
           python_callable=main,
           provide_context=True
       )
   ```
   
   ### Operating System
   
   Debian GNU/Linux 11 (bullseye)
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Astronomer
   
   ### Deployment details
   
   _No response_
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org.apache.org

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


[GitHub] [airflow] boring-cyborg[bot] commented on issue #24973: increasing ti.max_tries doesn't add more retries

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #24973:
URL: https://github.com/apache/airflow/issues/24973#issuecomment-1180690519

   Thanks for opening your first issue here! Be sure to follow the issue template!
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] potiuk commented on issue #24973: increasing ti.max_tries doesn't add more retries

Posted by GitBox <gi...@apache.org>.
potiuk commented on issue #24973:
URL: https://github.com/apache/airflow/issues/24973#issuecomment-1181668810

   Even if it worked before, that was purely accidental. This is almost certainly not an intention for the kwargs of tasks to be modified dynamically and it was never supposed to work like that. 


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] potiuk closed issue #24973: increasing ti.max_tries doesn't add more retries

Posted by GitBox <gi...@apache.org>.
potiuk closed issue #24973: increasing ti.max_tries doesn't add more retries
URL: https://github.com/apache/airflow/issues/24973


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

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