Skip to content

Store executor callback DagRun references in the database - #71214

Open
fat-catTW wants to merge 14 commits into
apache:mainfrom
fat-catTW:callback-dagrun-fkey
Open

fat-catTW wants to merge 14 commits into
apache:mainfrom
fat-catTW:callback-dagrun-fkey

Conversation

@fat-catTW

@fat-catTW fat-catTW commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Why

Executor callbacks need to know which DagRun they belong to when the scheduler builds callback workloads. Keeping that reference only in callback.data makes the scheduler depend on payload shape instead of a database-managed relationship.

Solution

Add a nullable callback.dagrun_id foreign key to dag_run.id and have executor callbacks store their DagRun reference there. The scheduler now loads the relationship through the ORM when enqueueing callback workloads.

The migration backfills existing rows from deadline relationships first, then falls back to legacy callback payload data when needed. Its upgrade and downgrade paths share the callback-payload deserialization logic.

To preserve archive behavior for airflow db clean -t dag_run, add callback to DagRun's dependent tables. Callback rows are then archived before their DagRun is deleted, rather than being removed by the foreign-key cascade.

Was generative AI tooling used to co-author this PR?
  • Yes — Codex

Generated-by: [Codex] following the guidelines

@fat-catTW
fat-catTW force-pushed the callback-dagrun-fkey branch 2 times, most recently from 40f7be8 to 26897c6 Compare August 9, 2026 15:00
@ferruzzi

Copy link
Copy Markdown
Contributor

I've merged everything in the chain that was blocking this; if you can get the migration rebased I can approve it and get it merged.

@fat-catTW
fat-catTW force-pushed the callback-dagrun-fkey branch from 0fb6db7 to aa3a9ee Compare October 16, 2026 04:36

@uranusjr uranusjr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description needs to be updated to mention the airflow db clean change.

@fat-catTW
fat-catTW force-pushed the callback-dagrun-fkey branch from efdf231 to 6aa6d2b Compare November 12, 2026 06:38
@fat-catTW

Copy link
Copy Markdown
Contributor Author

@uranusjr
Hello, I have updated the PR and mentioned the airflow db clean change in the description.
Could you take another look when you have time? Thanks

@jason810496 jason810496 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, here're some comments that make sense to me from the agentic review.

@ephraimbuddy ephraimbuddy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the three inline comments.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants