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

    <!-- SPDX-License-Identifier: Apache-2.0
         https://www.apache.org/licenses/LICENSE-2.0 -->
   
   <!--
   Thank you for contributing!
   
   Please provide above a brief description of the changes made in this pull 
request.
   Write a good git commit message following this guide: 
https://chris.beams.io/posts/git-commit/
   
   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.
   
   For user-facing UI changes, please attach before/after screenshots (or a 
short
   screen recording) so reviewers can assess the visual impact.
   
   Feel free to ping (in general) for the review if you do not see reaction for 
a few days
   (72 Hours is the minimum reaction time you can expect from volunteers) - we 
sometimes miss notifications.
   
   In case of an existing issue, reference it using one of the following:
   
   * closes: #ISSUE
   * related: #ISSUE
   -->
   
   ### What
   
   Durable execution lets a retry reconnect to an external job that is still 
running, or use the result of one that already finished, instead of starting it 
again. Users can't see when this happened or what it saved. The only trace is 
log lines and metrics.
   
   ### Current behaviour
   
   `ResumableJobMixin` sends its decision for each try (fresh submit, 
reconnect, already finished) to logs, metrics and spans only. Nothing in the UI 
shows that a retry avoided a rerun.
   
   ### Proposed change
   
   - Each try of a `ResumableJobMixin` operator writes what it did to 
`task_state_store` under the `__airflow_durable__` key, along with the job's 
submit time.
   - When a retry reconnects, the record is updated once the job finishes. The 
job's full run time counts as saved, because no second copy ran.
   - The logs page reads that record and shows a short banner above Task Tries 
for any try that reconnected or found the job already finished. It says how 
much job time was saved when that is known, and the job ID.
   
   ### Changes of Note
   
   - Time saved is the job's full run time, from submission to finish. Without 
durable execution, the retry would have started a fresh copy that runs the 
whole job again.
   - While a reconnected job is still running, the banner says "avoided a 
rerun" with no number. The number appears once the job finishes.
   - "Already finished" has no number, because the mixin doesn't know when that 
job ended.
   - Failing to write the record logs a warning and never fails the task.
   
   ### User implications / backcompat
   
   Nothing breaks. Durable tasks get one extra `__airflow_durable__` key in 
`task_state_store`, which shows up in the Task State Store tab. Clearing a task 
removes it together with the stored job ID.
   
   ### Testing
   
   Ran against a real Databricks job (three notebook tasks, about 2 minutes per 
run) with `DatabricksRunNowOperator`:
   - **Reconnect:** killed the task process mid-run. Try 2 reconnected and 
showed "avoided a rerun" while the job ran, then "saved ~2m 3s of job time" 
once it finished.
   - **Already finished:** the job finished while try 1 still failed. Try 2 
found it done in 2.8s and showed "avoided a rerun".
   - Try 1 shows no banner in both cases.
   
   **Img 1: Worker crash for try 1**
   
   <img width="3000" height="1800" alt="dbx_banner_reconnect_try1_done" 
src="https://github.com/user-attachments/assets/c2b04be2-4aeb-4f0f-8356-07c6bf9af4b7";
 />
   
   **Img 2: It shows that the retry reconnected (notice the running try 2)**
   
   <img width="3000" height="1800" alt="dbx_banner_reconnect_try2_running" 
src="https://github.com/user-attachments/assets/744a831e-7dd6-4505-a799-18e089d6ccc5";
 />
   
   
   **Img 3: Same as above but retry succeeded, so we show how much time was 
saved by not submitting databricks job again** 
   
   <img width="3000" height="1800" alt="dbx_banner_reconnect_try2_done" 
src="https://github.com/user-attachments/assets/9aedb3cc-befc-4cd1-b3c9-2a8f83b90cf1";
 />
   
   ```
   
   Time What happened
   17:47:42     Try 1 submits the job, and the record saves submitted_at
   17:48:31     I kill try 1's process; the job keeps running on Databricks
   17:48:43     Try 2 reconnects to the same job
   17:49:45     The job finishes; try 2 updates the record
   
   17:49:45 minus 17:47:42 = 123 seconds = 2m 3s.
   ```
   
   
   **Img 4: If try 2 came back up when dbx job succeeded**
   
   
   
   <img width="3000" height="1800" alt="dbx_banner_finished_try2_done" 
src="https://github.com/user-attachments/assets/f048b2e6-aea7-4c45-93be-23d3f4082c8b";
 />
   
   
   
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, 
please
   change below checkbox to `[X]` followed by the name of the tool, uncomment 
the "Generated-by".
   -->
   
   - [x] Yes - claude
   
   <!--
   Generated-by: [Tool Name] following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   -->
   
   ---
   
   * Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
 for more information. Note: commit author/co-author name and email in commits 
become permanently public when merged.
   * For fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   * When adding dependency, check compliance with the [ASF 3rd Party License 
Policy](https://www.apache.org/legal/resolved.html#category-x).
   * For significant user-facing changes create newsfragment: 
`{pr_number}.significant.rst`, in 
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
 You can add this file in a follow-up commit after the PR is created so you 
know the PR number.
   


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