Skip to content

Add bulk XCom deletion to Execution API#59874

Open
justinpakzad wants to merge 1 commit into
apache:mainfrom
justinpakzad:feature/delete-all-xcoms-associate-dag-run
Open

Add bulk XCom deletion to Execution API#59874
justinpakzad wants to merge 1 commit into
apache:mainfrom
justinpakzad:feature/delete-all-xcoms-associate-dag-run

Conversation

@justinpakzad

@justinpakzad justinpakzad commented Dec 28, 2025

Copy link
Copy Markdown
Contributor

This PR implements bulk XCom deletion functionality. The issue was that it's not possible to delete all XComs for a dag run using the XCom.delete() method since task_id and key are required arguments. Given there is no direct database access, adding bulk deletion functionality would allow users to run clean up tasks at the end of their Dags, which can help prevent db bloat when the Xcoms don't really have much archival value.

I added a new bulk_delete_xcoms() endpoint to the execution API with task_id and key as optional query parameters. This allows a user to just pass in dag_id and run_id to delete all XComs associated with that run.

A delete_all() method was added to the BaseXCom class as well as the associated method in the client which calls the execution API. New message type was added to the supervisor and trigger job runner.

I created tests to cover the different deletion patterns: deleting all XComs for a run, deleting all keys for a specific task, and deleting a specific key across all tasks. Cadwyn migration file was also updated with the new change.

closes: #57812


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@boring-cyborg boring-cyborg Bot added area:API Airflow's REST/HTTP API area:task-sdk labels Dec 28, 2025
Comment thread airflow-core/src/airflow/api_fastapi/execution_api/routes/xcoms.py Outdated
@justinpakzad justinpakzad force-pushed the feature/delete-all-xcoms-associate-dag-run branch 5 times, most recently from 80df148 to 5eef562 Compare January 5, 2026 16:30
@justinpakzad

Copy link
Copy Markdown
Contributor Author

Just following up here - I implemented the suggestions about the XCom.delete() parameters. Let me know if the approach looks sound.

@jscheffl jscheffl requested a review from amoghrajesh January 7, 2026 18:36
@uranusjr

uranusjr commented Jan 9, 2026

Copy link
Copy Markdown
Member

This will need a migration to move existing calls to the new endpoint (since the path has changed).

Comment thread airflow-core/src/airflow/api_fastapi/execution_api/routes/xcoms.py
Comment thread airflow-core/src/airflow/api_fastapi/execution_api/routes/xcoms.py Outdated
@justinpakzad justinpakzad force-pushed the feature/delete-all-xcoms-associate-dag-run branch from 5eef562 to e2e8422 Compare January 12, 2026 23:56
@eladkal eladkal added this to the Airflow 3.2.0 milestone Jan 13, 2026
@justinpakzad justinpakzad force-pushed the feature/delete-all-xcoms-associate-dag-run branch from f7c9646 to dae61bb Compare January 24, 2026 20:39
@justinpakzad justinpakzad force-pushed the feature/delete-all-xcoms-associate-dag-run branch 2 times, most recently from 8ef2514 to 1c60599 Compare January 31, 2026 02:07
@justinpakzad justinpakzad force-pushed the feature/delete-all-xcoms-associate-dag-run branch from 1c60599 to f104dfb Compare March 3, 2026 23:10
@justinpakzad

justinpakzad commented Mar 4, 2026

Copy link
Copy Markdown
Contributor Author

Updated the has_xcom_access func to make task_id and key optional as suggested. Doing so allows the router level dependency to be compatible with the bulk endpoint.

@justinpakzad justinpakzad force-pushed the feature/delete-all-xcoms-associate-dag-run branch from f104dfb to ffaddec Compare March 4, 2026 03:27
@justinpakzad

Copy link
Copy Markdown
Contributor Author

@amoghrajesh, not usually one to tag but I couldn't re-request review. Do you mind taking a look at the updates whenever you have a chance. Thanks.

@potiuk

potiuk commented Mar 10, 2026

Copy link
Copy Markdown
Member

Please rebase. You have conflicts.

@justinpakzad justinpakzad force-pushed the feature/delete-all-xcoms-associate-dag-run branch from ffaddec to 387db67 Compare March 11, 2026 01:26
@justinpakzad justinpakzad force-pushed the feature/delete-all-xcoms-associate-dag-run branch 2 times, most recently from a0cd44c to 7198380 Compare May 1, 2026 12:50
@justinpakzad

Copy link
Copy Markdown
Contributor Author

Apologies for the delay, last few comments, looking much better now

Thanks for the review! Addressed all the comments. The bulk delete endpoint now returns the count of deleted rows instead of the generic message. The client then returns a XComDeleteCountResponse. Fixed the dup test_id and added another test in the supervisor for the map_index.

@justinpakzad justinpakzad force-pushed the feature/delete-all-xcoms-associate-dag-run branch from 7198380 to 9c1e1b9 Compare May 4, 2026 20:59
@justinpakzad justinpakzad requested a review from amoghrajesh May 4, 2026 22:21
@justinpakzad justinpakzad force-pushed the feature/delete-all-xcoms-associate-dag-run branch 3 times, most recently from 76887d5 to f877346 Compare May 14, 2026 01:18
@justinpakzad

Copy link
Copy Markdown
Contributor Author

@amoghrajesh Can you give this another review when you have a chance? Addressed all of your most recent comments. Thanks.

@justinpakzad justinpakzad force-pushed the feature/delete-all-xcoms-associate-dag-run branch from f877346 to 7421401 Compare May 22, 2026 02:50
@potiuk

potiuk commented May 24, 2026

Copy link
Copy Markdown
Member

@amoghrajesh@justinpakzad addressed your feedback on this PR back in May (most recent push: 2026-05-14) and the CHANGES_REQUESTED state has now been blocking the PR for ~5 months. Could you either re-review and dismiss / re-approve, or explicitly dismiss the request-changes if your concerns are addressed?

@eladkal mentioned earlier we wanted this in 3.2.0 — happy to have someone else take a look if you don't have bandwidth, just let us know.


Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes.


Drafted-by: Claude Code (Opus 4.7); reviewed by @potiuk before posting

@justinpakzad justinpakzad force-pushed the feature/delete-all-xcoms-associate-dag-run branch 3 times, most recently from f0d8d48 to e66f192 Compare June 4, 2026 21:11
@justinpakzad

Copy link
Copy Markdown
Contributor Author

@amoghrajesh do you mind giving this another review? Would love to get this merged. I addressed all of your previous comments and I also made updates to follow the new request_handlers pattern, so that it's aligned with all the rest. Thanks.

@justinpakzad justinpakzad force-pushed the feature/delete-all-xcoms-associate-dag-run branch from e66f192 to e9078b6 Compare June 6, 2026 13:58
@potiuk potiuk removed the ready for maintainer review Set after triaging when all criteria pass. label Jun 9, 2026
@potiuk

potiuk commented Jun 9, 2026

Copy link
Copy Markdown
Member

@justinpakzad — Changes have been requested on this PR, so I've removed the ready for maintainer review label — the next step is on your side. Could you address the review comments (push a fix, or reply in-thread explaining why the feedback doesn't apply)? Once addressed, re-mark the PR ready and it returns to the maintainer queue. Thank you.

Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you.

@justinpakzad

justinpakzad commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@justinpakzad — Changes have been requested on this PR, so I've removed the ready for maintainer review label — the next step is on your side. Could you address the review comments (push a fix, or reply in-thread explaining why the feedback doesn't apply)? Once addressed, re-mark the PR ready and it returns to the maintainer queue. Thank you.

@potiuk The changes requested had been addressed quite a while ago and I have consistently pushed fixes for all other review comments. Been awaiting for another review on this. Would appreciate if this was added back to the maintainer queue.

@jroachgolf84

Copy link
Copy Markdown
Collaborator

cc: @ashb

@justinpakzad justinpakzad force-pushed the feature/delete-all-xcoms-associate-dag-run branch 3 times, most recently from c8bb987 to 668ff4a Compare June 14, 2026 18:11
@justinpakzad

Copy link
Copy Markdown
Contributor Author

Would really appreciate another review on this.

@justinpakzad justinpakzad changed the title Added bulk XCom deletion support to Task Execution API Add bulk XCom deletion to Execution API Jun 16, 2026
@justinpakzad justinpakzad force-pushed the feature/delete-all-xcoms-associate-dag-run branch from 668ff4a to b093bf7 Compare June 16, 2026 21:47
Add a DELETE /xcoms/{dag_id}/{run_id} endpoint that
deletes all XCom entries for a Dag run, with optional
task_id, key, and map_index filters. Returns the count
of deleted rows.
@justinpakzad justinpakzad force-pushed the feature/delete-all-xcoms-associate-dag-run branch from b093bf7 to 988b548 Compare June 17, 2026 00:33
@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Jun 17, 2026
@justinpakzad

Copy link
Copy Markdown
Contributor Author

@ashb would you mind giving this a review when you have a moment?

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

Labels

area:API Airflow's REST/HTTP API area:task-sdk ready for maintainer review Set after triaging when all criteria pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possibility to delete all xcoms associated to a dag run using XCom.delete() function.

8 participants