Repository navigation
Reduce memory used when deleting queued asset events - #71917
Merged
pierrejeambrun merged 1 commit intoAug 21, 2026
Merged
pierrejeambrun merged 1 commit into
pierrejeambrun merged 1 commit into
Conversation
delete_asset_queued_events and delete_dag_asset_queued_event forced SQLAlchemy's "fetch" synchronize_session strategy on their AssetDagRunQueue deletes. That strategy reads the primary key of every deleted row back from the database to update the ORM session's identity map, but neither endpoint loads any AssetDagRunQueue objects into the session beforehand, so the read-back keys are matched against an empty map and discarded. The sibling delete_dag_asset_queued_events endpoint already used the default "auto" strategy; the other two now match it.
ColtenOuO
requested review from
bugraoz93,
choo121600,
ephraimbuddy,
henry3260,
jason810496,
pierrejeambrun,
rawwar and
shubhamraj-git
as code owners
August 20, 2026 19:37
1 task done
Contributor
Backport successfully created: v3-3-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
github-actions Bot
pushed a commit
to aws-mwaa/upstream-to-airflow
that referenced
this pull request
Aug 21, 2026
…che#71917) delete_asset_queued_events and delete_dag_asset_queued_event forced SQLAlchemy's "fetch" synchronize_session strategy on their AssetDagRunQueue deletes. That strategy reads the primary key of every deleted row back from the database to update the ORM session's identity map, but neither endpoint loads any AssetDagRunQueue objects into the session beforehand, so the read-back keys are matched against an empty map and discarded. The sibling delete_dag_asset_queued_events endpoint already used the default "auto" strategy; the other two now match it. (cherry picked from commit 49c5d51) Co-authored-by: Jyun-An Chen <jun930436@gmail.com>
aws-airflow-bot
pushed a commit
to aws-mwaa/upstream-to-airflow
that referenced
this pull request
Aug 21, 2026
…che#71917) delete_asset_queued_events and delete_dag_asset_queued_event forced SQLAlchemy's "fetch" synchronize_session strategy on their AssetDagRunQueue deletes. That strategy reads the primary key of every deleted row back from the database to update the ORM session's identity map, but neither endpoint loads any AssetDagRunQueue objects into the session beforehand, so the read-back keys are matched against an empty map and discarded. The sibling delete_dag_asset_queued_events endpoint already used the default "auto" strategy; the other two now match it. (cherry picked from commit 49c5d51) Co-authored-by: Jyun-An Chen <jun930436@gmail.com>
jason810496
pushed a commit
that referenced
this pull request
Aug 22, 2026
) (#71937) delete_asset_queued_events and delete_dag_asset_queued_event forced SQLAlchemy's "fetch" synchronize_session strategy on their AssetDagRunQueue deletes. That strategy reads the primary key of every deleted row back from the database to update the ORM session's identity map, but neither endpoint loads any AssetDagRunQueue objects into the session beforehand, so the read-back keys are matched against an empty map and discarded. The sibling delete_dag_asset_queued_events endpoint already used the default "auto" strategy; the other two now match it. (cherry picked from commit 49c5d51) Co-authored-by: Jyun-An Chen <jun930436@gmail.com>
vatsrahul1001
pushed a commit
that referenced
this pull request
Sep 7, 2026
) (#71937) delete_asset_queued_events and delete_dag_asset_queued_event forced SQLAlchemy's "fetch" synchronize_session strategy on their AssetDagRunQueue deletes. That strategy reads the primary key of every deleted row back from the database to update the ORM session's identity map, but neither endpoint loads any AssetDagRunQueue objects into the session beforehand, so the read-back keys are matched against an empty map and discarded. The sibling delete_dag_asset_queued_events endpoint already used the default "auto" strategy; the other two now match it. (cherry picked from commit 49c5d51) Co-authored-by: Jyun-An Chen <jun930436@gmail.com>
imrichardwu
pushed a commit
to imrichardwu/airflow
that referenced
this pull request
Sep 11, 2026
delete_asset_queued_events and delete_dag_asset_queued_event forced SQLAlchemy's "fetch" synchronize_session strategy on their AssetDagRunQueue deletes. That strategy reads the primary key of every deleted row back from the database to update the ORM session's identity map, but neither endpoint loads any AssetDagRunQueue objects into the session beforehand, so the read-back keys are matched against an empty map and discarded. The sibling delete_dag_asset_queued_events endpoint already used the default "auto" strategy; the other two now match it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #71185:
delete_asset_queued_eventsanddelete_dag_asset_queued_event(airflow-core/src/airflow/api_fastapi/core_api/routes/public/assets.py) still forced SQLAlchemy's"fetch"synchronize_sessionstrategy on theirAssetDagRunQueuedeletes - the exact pattern #71185 removed fromdelete_dag."fetch"reads the primary key of every deleted row back from the database (viaRETURNINGon backends that support it, or an extraSELECTbeforehand on those that don't) so it can update the ORM session's identity map. Neither endpoint loads anyAssetDagRunQueueobjects 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 siblingdelete_dag_asset_queued_eventsendpoint 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):synchronize_session"fetch"(before)DELETE … RETURNING …)DELETE)"fetch"(before)DELETE … RETURNING …)DELETE)Changes
assets.pydelete_asset_queued_eventssynchronize_session="fetch""auto")assets.pydelete_dag_asset_queued_eventsynchronize_session="fetch""auto")Was generative AI tooling used to co-author this PR?