jgoedeke opened a new issue, #70779:
URL: https://github.com/apache/airflow/issues/70779

   ### Under which category would you file this issue?
   
   Providers
   
   ### Apache Airflow version
   
   3.3.0
   
   ### What happened and how to reproduce it?
   
   `GET /ui/dags/{dag_id}/deadlineAlerts` loads every historical 
`serialized_dag` row for the DAG.
   
   In 
[`airflow.api_fastapi.core_api.routes.ui.deadlines.get_dag_deadline_alerts`](https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/deadlines.py#L176-L180),
 the lookup is ordered descending but has no SQL `LIMIT`:
   
   ```python
   serialized_dag = session.scalar(
       select(SerializedDagModel)
       .where(SerializedDagModel.dag_id == dag_id)
       .order_by(SerializedDagModel.id.desc())
   )
   ```
   
   For a DAG with 6,725 historical serialized DAG versions totaling about 4 
GiB, PostgreSQL returned all rows and the API process exceeded its memory limit 
and was OOM-killed.
   
   Add historical rows for one `dag_id`, then request:
   
   ```text
   /ui/dags/<dag_id>/deadlineAlerts
   ```
   
   The query should retrieve only the newest serialized DAG row.
   
   
   
   ### What you think should happen instead?
   
   The query should include `.limit(1)` before calling `session.scalar()`:
   
   ```python
   .order_by(SerializedDagModel.id.desc())
   .limit(1)
   ```
   
   This returns only the latest serialized DAG and prevents memory usage from 
scaling with historical DAG-version count.
   
   ### Operating System
   
   _No response_
   
   ### Deployment
   
   None
   
   ### Apache Airflow Provider(s)
   
   _No response_
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Official Helm Chart version
   
   Not Applicable
   
   ### Kubernetes Version
   
   _No response_
   
   ### Helm Chart configuration
   
   _No response_
   
   ### Docker Image customizations
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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