kimyen opened a new pull request, #36078:
URL: https://github.com/apache/airflow/pull/36078

   <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
   
      http://www.apache.org/licenses/LICENSE-2.0
   
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ### Use case
   We use Airflow to build our data pipelines. Our Airflow DAG graph includes 
600+ DAGs, highly dependent on one another. A DAG may include ingestion for 
multiple tables from the same source. A downstream DAG may only need data from 
a single table and only need to take dependency on a single task instead of an 
entire DAG.
   
   Occasionally when an upstream DAG timeout due to whatever reason (higher 
volume of data, infrastructure issues, ...) we have an on-call rotation that 
fixes the issues based on the severity of the DAG. In general, we value no data 
over wrong/missing data. Hence, when an upstream DAG timeout, we would address 
the issue and ensure the upstream DAG rerun successfully prior to re-enable 
(clear) all the downstream DAGs. 
   
   With the default settings, when the DAG timeout, the unfinished tasks are 
marked as `skipped`, which is a successful state. With this, downstream DAG 
whose depends on the unfinished task will start even though the data not yet 
arrived/ not completed.
   
   We previously fork `apache/airflow` to change this behavior to mark 
unfinished tasks as `failed`. We are working on getting rid of our fork and 
hope that we can expose this option to modify the state of unfinished tasks for 
our use case.
   
   ### Other considerations
   
   Alternatively, with dataset, we can eventually convert our (600+) DAGs to 
depend on the data arriving rather than the upstream task instance. However, we 
are currently running Airflow 2.0.2 and working on upgrading to Airflow 2.7. 
Making our DAG depends on dataset is not yet available for our users. This 
change will enable us upgrade directly to `apache/airflow` v2.7 without 
maintaining our fork nor impacting our users.
   
   ### Summary of changes
   
   This pull request introduces a new configuration parameter 
`default_unfinished_ti_state` under `core` section. This parameter is used to 
define the state of unfinished tasks when a DAG times out. The changes involve 
adding the new configuration parameter in the `config.yml` file and modifying 
the `_schedule_dag_run` method in `scheduler_job_runner.py` to use this new 
parameter.
   
   Configuration changes:
   
   * <a 
href="diffhunk://#diff-0a480a8b563e200f749424d7e761555e543588ff39a0b11cce7e34d522f38e0eR258-R264">`airflow/config_templates/config.yml`</a>:
 Introduced a new configuration parameter `default_unfinished_ti_state` under 
the `core` section. This parameter is used to specify the state of unfinished 
tasks when a DAG times out. The default value for this parameter is set to 
"skipped".
   
   Code changes:
   
   * <a 
href="diffhunk://#diff-b0491913f69327937706aea8fc77a71efeb979897898e405ade2b162ad862476R1461-R1463">`airflow/jobs/scheduler_job_runner.py`</a>:
 In the `_schedule_dag_run` method, the state of unfinished tasks is now set to 
the value of the new configuration parameter `default_unfinished_ti_state` 
instead of being hard-coded to `TaskInstanceState.SKIPPED`.
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)**
 for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party 
License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a 
newsfragment file, named `{pr_number}.significant.rst` or 
`{issue_number}.significant.rst`, in 
[newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to