Uh oh!
There was an error while loading. Please reload this page.
Isolate scheduled DagRun creation failures with savepoints - #71287
Open
fat-catTW wants to merge 2 commits into
Open
Isolate scheduled DagRun creation failures with savepoints#71287fat-catTW wants to merge 2 commits into
fat-catTW wants to merge 2 commits into
Conversation
fat-catTWforce-pushed
the
fix-dagrun-creation-savepoint
branch
from
August 8, 2026 10:24
f5e6d6f to
e9deb87Comparesteveahnahn
approved these changes
Aug 11, 2026
steveahnahn
left a comment
Contributor
There was a problem hiding this comment.
Nice work! Reverting the savepoint wrapping reproduces the poisoned-transaction failure and the fix clears it LGTM aside from the one nit
Uh oh!
There was an error while loading. Please reload this page.
A single database error while creating a scheduled DagRun can leave the scheduler session in a failed transaction state. That prevents the scheduler from reliably continuing with other healthy Dags in the same batch.
fat-catTWforce-pushed
the
fix-dagrun-creation-savepoint
branch
from
August 12, 2026 06:19
e9deb87 to
ac70c7dCompare
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 freeto 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.
Why
SchedulerJobRunner._create_dag_runscatches exceptions while creating scheduled DagRuns and then continues with the next Dag. This does not work reliably when the failure is caused by a database error, because the SQLAlchemy session can be left in a failed transaction state.When that happens, one failing DagRun creation attempt can prevent the scheduler from creating DagRuns for other healthy Dags in the same batch.
Solution
Wrap each scheduled DagRun creation attempt in a nested transaction/savepoint. If a database-level failure happens for one Dag, only that DagRun creation attempt is rolled back and the outer scheduler transaction remains usable.
The in-memory active run counter is updated only after the savepoint succeeds, keeping scheduler state aligned with the database transaction outcome.
A regression test covers a flush-time database failure for one Dag and verifies that another Dag in the same batch still creates its DagRun successfully.
relates: #59120
[X]Yes (please specify the tool below)Generated-by: [Codex] following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.