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

[PR] Keep get_dag_details and get_pools database queries off the API server event loop [airflow]

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

   FastAPI validates a sync route's response in the threadpool but serializes it on the event loop. Two public API responses were still hitting the database during serialization, so when the SQLAlchemy pool was exhausted the whole API server stalled on the pool checkout until `pool_timeout` expired.
   
   - `DAGDetailsResponse.latest_dag_version` was a computed field that opened its own session to load the latest DagVersion. `get_dag_details` now loads it through the request session and sets it on the model, like `is_favorite` and `active_runs_count`, and `latest_dag_version` is a regular field. This also drops the second connection each `/details` request was taking.
   - `PoolCollectionResponse.pools` was `Iterable[PoolResponse]`, which pydantic validates lazily during serialization, so the six slot queries per pool ran inside `dump_json`. It is now `list[PoolResponse]`, so they run when the route builds the response in the threadpool.
   
   In the OpenAPI schema `latest_dag_version` stays required and nullable, but it is no longer marked `readOnly`. I regenerated the spec, the UI client and the airflow-ctl datamodels.
   
   The new tests record SQL statements executed on the event loop thread while serving `/dags/{dag_id}/details` and `/pools`. Without the change they catch 1 and 24 statements respectively.
   
   closes: #74239
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [ ] Yes (please specify the tool below)
   
   ---
   
   * 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: commits-unsubscribe@airflow.apache.org

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


Re: [PR] Keep get_dag_details and get_pools database queries off the API server event loop [airflow]

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


-- 
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] Keep get_dag_details and get_pools database queries off the API server event loop [airflow]

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

   ### Backport failed to create: airflow-ctl/v0-1-test. View the failure log <a href='https://github.com/apache/airflow/actions/runs/37621327047'> 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>airflow-ctl/v0-1-test</td>
           <td><a href="https://github.com/apache/airflow/commit/9af3db036397efef60a4a1b1f02b123f640aaebe"><img src='https://img.shields.io/badge/Commit-9af3db0-red' alt='Commit Link'></a></td>
       </tr>
   </table>
   
   You can attempt to backport this manually by running:
   
   ```bash
   cherry_picker 9af3db0 airflow-ctl/v0-1-test
   ```
   
   This should apply the commit to the airflow-ctl/v0-1-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