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

   ## Summary
   
   Follow-up to #71185: `delete_asset_queued_events` and 
`delete_dag_asset_queued_event` 
(`airflow-core/src/airflow/api_fastapi/core_api/routes/public/assets.py`) still 
forced SQLAlchemy's `"fetch"` `synchronize_session` strategy on their 
`AssetDagRunQueue` deletes - the exact pattern #71185 removed from `delete_dag`.
   
   `"fetch"` reads the primary key of every deleted row back from the database 
(via `RETURNING` on backends that support it, or an extra `SELECT` beforehand 
on those that don't) so it can update the ORM session's identity map. Neither 
endpoint loads any `AssetDagRunQueue` objects into the session before the 
delete, so those keys are matched against an empty map and discarded - 
transient Python heap allocated per deleted row for no reason. The sibling 
`delete_dag_asset_queued_events` endpoint already used the default `"auto"` 
strategy; this brings the other two in line with it.
   
   ### Before / after
   
   50,000 rows shaped like `asset_dag_run_queue` (composite `(target_dag_id, 
asset_event_id)` primary key, `asset_id`, `created_at`):
   
   | backend | `synchronize_session` | time | peak heap | statements |
   |---|---|---|---|---|
   | PostgreSQL 14 | `"fetch"` (before) | 0.750s | 14.2 MiB | 1 (`DELETE … 
RETURNING …`) |
   | PostgreSQL 14 | default (after) | **0.045s** | **0.0 MiB** | 1 (`DELETE`) |
   | SQLite | `"fetch"` (before) | 0.779s | 14.2 MiB | 1 (`DELETE … RETURNING 
…`) |
   | SQLite | default (after) | **0.046s** | **0.0 MiB** | 1 (`DELETE`) |
   
   ## Changes
   
   | File | Function | Before | After |
   |---|---|---|---|
   | `assets.py` | `delete_asset_queued_events` | `synchronize_session="fetch"` 
| default (`"auto"`) |
   | `assets.py` | `delete_dag_asset_queued_event` | 
`synchronize_session="fetch"` | default (`"auto"`) |
   
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Sonnet 5) for writing test
   


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