kaxil commented on a change in pull request #17819: URL: https://github.com/apache/airflow/pull/17819#discussion_r710539698
########## File path: tests/models/test_taskinstance.py ########## @@ -1683,6 +1683,21 @@ def test_handle_failure(self, create_dummy_dag, session=None): assert context_arg_3 and "task_instance" in context_arg_3 mock_on_retry_3.assert_not_called() + def test_handle_failure_updates_queued_task_try_number(self, dag_maker): + session = settings.Session() + with dag_maker(): + task = DummyOperator(task_id="mytask", retries=1) + dr = dag_maker.create_dagrun() + ti = TI(task=task, run_id=dr.run_id) + ti.state = State.QUEUED + session.merge(ti) + session.commit() + assert ti.state == State.QUEUED + assert ti.try_number == 1 + ti.handle_failure("test queued ti", test_mode=True) + assert ti.state == State.UP_FOR_RETRY + assert ti.try_number == 3 Review comment: Yeah - `try_number` get's bumped to 2 in https://github.com/apache/airflow/blob/550ca654cd1b6c2e97a4174c3950a17093747880/airflow/models/taskinstance.py#L1722-L1723 and when `ti.try_number` is accessed here: https://github.com/apache/airflow/blob/550ca654cd1b6c2e97a4174c3950a17093747880/airflow/models/taskinstance.py#L467-L480 since it is not running and in `UP_FOR_RETRY` state, the `try_number` is set to `3`. -- 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-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org