You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Revanth14 (via GitHub)" <gi...@apache.org> on 2026/06/01 00:51:55 UTC

[PR] Fix scheduler orphaned task reset logging crash [airflow]

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

   
   ---
   Fixes: #67813
   
   The scheduler orphaned-task adoption path loaded task instances with a narrow `load_only(...)` set and then called `repr(ti)` while building the reset log message. `TaskInstance.__repr__` reads `map_index` and `state`, so detached
   instances with deferred columns could raise `DetachedInstanceError` and crash the scheduler on restart.
   
   This updates the scheduler query to load the fields needed by `repr(ti)` and makes `TaskInstance.__repr__` defensive for detached/deleted ORM instances used in logging.
   
   Tests:
   - `uv run --project airflow-core pytest airflow-core/tests/unit/models/test_taskinstance.py::test_task_instance_repr_does_not_raise_for_deferred_columns airflow-core/tests/unit/jobs/test_scheduler_job.py::TestSchedulerJob::test_adopt_or_reset_orphaned_tasks_loads_state_for_reset_logging -q`
     - 2 passed
   
   ##### 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 (please specify the tool below)
   
   <!--
   Generated-by: [Opus 4.8] following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   -->
   


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


Re: [PR] Fix scheduler orphaned task reset logging crash [airflow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #67822:
URL: https://github.com/apache/airflow/pull/67822#issuecomment-4592475056

   Hi maintainer, this PR was merged without a milestone set.
   We've automatically set the milestone to **[Airflow 3.2.3](https://github.com/apache/airflow/milestone/140)** based on: backport label targeting v3-2-test
   If this milestone is not correct, please update it to the appropriate milestone.
   
   > This comment was generated by [Milestone Tag Assistant](https://github.com/apache/airflow/blob/main/.github/workflows/milestone-tag-assistant.yml).
   


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


Re: [PR] Fix scheduler orphaned task reset logging crash [airflow]

Posted by "Pedrinhonitz (via GitHub)" <gi...@apache.org>.
Pedrinhonitz commented on code in PR #67822:
URL: https://github.com/apache/airflow/pull/67822#discussion_r3331233964


##########
airflow-core/newsfragments/67822.bugfix.rst:
##########
@@ -0,0 +1 @@
+Fix scheduler crash (``DetachedInstanceError``) when logging orphaned task resets by loading the columns ``TaskInstance.__repr__`` needs and hardening it against deferred attributes.

Review Comment:
   We do not add new fragments for bug fixes in this format, please revert or remove them.



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


Re: [PR] Fix scheduler orphaned task reset logging crash [airflow]

Posted by "Revanth14 (via GitHub)" <gi...@apache.org>.
Revanth14 commented on code in PR #67822:
URL: https://github.com/apache/airflow/pull/67822#discussion_r3331242683


##########
airflow-core/newsfragments/67822.bugfix.rst:
##########
@@ -0,0 +1 @@
+Fix scheduler crash (``DetachedInstanceError``) when logging orphaned task resets by loading the columns ``TaskInstance.__repr__`` needs and hardening it against deferred attributes.

Review Comment:
   Done, removed the newsfragment. Thanks for the heads up!



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


Re: [PR] Fix scheduler orphaned task reset logging crash [airflow]

Posted by "Revanth14 (via GitHub)" <gi...@apache.org>.
Revanth14 commented on code in PR #67822:
URL: https://github.com/apache/airflow/pull/67822#discussion_r3331242683


##########
airflow-core/newsfragments/67822.bugfix.rst:
##########
@@ -0,0 +1 @@
+Fix scheduler crash (``DetachedInstanceError``) when logging orphaned task resets by loading the columns ``TaskInstance.__repr__`` needs and hardening it against deferred attributes.

Review Comment:
   Done, removed the new fragment. Thanks for the heads up!



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


Re: [PR] Fix scheduler orphaned task reset logging crash [airflow]

Posted by "LukePaytec (via GitHub)" <gi...@apache.org>.
LukePaytec commented on PR #67822:
URL: https://github.com/apache/airflow/pull/67822#issuecomment-4668101778

   Does anyone know what version does not have this issue? I need to drop back down to that one? @Revanth14 would you know?


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


Re: [PR] Fix scheduler orphaned task reset logging crash [airflow]

Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #67822:
URL: https://github.com/apache/airflow/pull/67822#discussion_r3333469197


##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2851,7 +2851,16 @@ def adopt_or_reset_orphaned_tasks(self, *, session: Session = NEW_SESSION) -> in
                         .where(Job.state.is_distinct_from(JobState.RUNNING))
                         .join(TI.dag_run)
                         .where(DagRun.state == DagRunState.RUNNING)
-                        .options(load_only(TI.dag_id, TI.task_id, TI.run_id, TI.external_executor_id))
+                        .options(
+                            load_only(
+                                TI.dag_id,

Review Comment:
   ```suggestion
                                   TI.id,
                                   TI.dag_id,
   ```



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


Re: [PR] Fix scheduler orphaned task reset logging crash [airflow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #67822:
URL: https://github.com/apache/airflow/pull/67822#issuecomment-4592477195

   ### Backport failed to create: v3-2-test. View the failure log <a href='https://github.com/apache/airflow/actions/runs/26754213614'> Run details </a>
   
   Note: As of [Merging PRs targeted for Airflow 3.X](https://github.com/apache/airflow/blob/main/dev/README_AIRFLOW3_DEV.md#merging-prs-targeted-for-airflow-3x)
   the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.
   
   In matter of doubt please ask in [#release-management](https://apache-airflow.slack.com/archives/C03G9H97MM2) Slack channel.
   
   <table>
       <tr>
           <th>Status</th>
           <th>Branch</th>
           <th>Result</th>
       </tr>
       <tr>
           <td>❌</td>
           <td>v3-2-test</td>
           <td><a href="https://github.com/apache/airflow/commit/8395c29ffd518e2daf7f23094d0c76e95adb6256"><img src='https://img.shields.io/badge/Commit-8395c29-red' alt='Commit Link'></a></td>
       </tr>
   </table>
   
   You can attempt to backport this manually by running:
   
   ```bash
   cherry_picker 8395c29 v3-2-test
   ```
   
   This should apply the commit to the v3-2-test branch and leave the commit in conflict state marking
   the files that need manual conflict resolution.
   
   After you have resolved the conflicts, you can continue the backport process by running:
   
   ```bash
   cherry_picker --continue
   ```
   
   If you don't have cherry-picker installed, see the [installation guide](https://github.com/apache/airflow/blob/main/dev/README.md#how-to-backport-pr-with-cherry-picker-cli).
   


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


Re: [PR] Fix scheduler orphaned task reset logging crash [airflow]

Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb merged PR #67822:
URL: https://github.com/apache/airflow/pull/67822


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