Repository navigation
Fix airflow db clean hang on MySQL when delete fails - #66296
Conversation
|
@Vamsi-klu can you close your PR, I have made the fix 4 days ago and waiting for the #PR-66249 approval for merge and close this issue. |
|
@Vamsi-klu A few things need addressing before review — see our Pull Request quality criteria.
No rush. 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. Drafted-by: Claude Code (Opus 4.7); reviewed by @potiuk before posting |
This comment was marked as spam.
This comment was marked as spam.
ephraimbuddy
left a comment
There was a problem hiding this comment.
I think this will solve the hang but the cleanup would still raise on every dag with run history since dagversion is fk-pinned to task_instance.
The newsfragments is not necessary.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
aaron-y-chen
left a comment
There was a problem hiding this comment.
Hi, thanks for the fix! While testing this, I found a small edge case where the cleanup path can still mask the original delete error. Would you mind fixing it in this PR as well? :)
The check-newsfragment-pr-number CI job requires the newsfragment filename to match the PR number, not the linked issue number.
Keeps the hang-regression tests meaningful once dag_version cleanup learns to skip FK-pinned rows (apache#68339).
When _do_delete unwinds from a failed DELETE, dropping the archive table in the finally block could itself raise (e.g. a dead connection on MySQL). Python makes a finally-raised error the top-level exception, so that cleanup error would replace the original delete failure -- and an OperationalError from the drop could then be downgraded to a warning by _suppress_with_logging, silently masking the real IntegrityError. Guard the cleanup so it only propagates on the success path; on the failure path it is logged and the original error survives.
This comment was marked as spam.
This comment was marked as spam.
ephraimbuddy
left a comment
There was a problem hiding this comment.
We shouldn't have PR numbers on tests doc strings
Co-authored-by: Ephraim Anierobi <splendidzigy24@gmail.com>
This comment was marked as spam.
This comment was marked as spam.
The previous run failed because the Mongo provider test fixture could not connect to its temporary mongod container. No source change is needed; this commit retriggers CI so the PR can use a fresh signal.
* Fix airflow db clean hang on MySQL when delete fails (apache#66177) * Rename newsfragment to match PR number The check-newsfragment-pr-number CI job requires the newsfragment filename to match the PR number, not the linked issue number. * Remove newsfragment per review * Suppress rollback errors so the original delete error propagates * Explain why the archive table drop reuses the session connection * Force the FK-failure path in backend regression tests via config copy Keeps the hang-regression tests meaningful once dag_version cleanup learns to skip FK-pinned rows (apache#68339). * Guard archive-table cleanup so it can't mask the original delete error When _do_delete unwinds from a failed DELETE, dropping the archive table in the finally block could itself raise (e.g. a dead connection on MySQL). Python makes a finally-raised error the top-level exception, so that cleanup error would replace the original delete failure -- and an OperationalError from the drop could then be downgraded to a warning by _suppress_with_logging, silently masking the real IntegrityError. Guard the cleanup so it only propagates on the success path; on the failure path it is logged and the original error survives. * Update airflow-core/tests/unit/utils/test_db_cleanup.py Co-authored-by: Ephraim Anierobi <splendidzigy24@gmail.com> * Retry CI after provider compat startup failure The previous run failed because the Mongo provider test fixture could not connect to its temporary mongod container. No source change is needed; this commit retriggers CI so the PR can use a fresh signal. --------- Co-authored-by: Ephraim Anierobi <splendidzigy24@gmail.com> Co-authored-by: Ramachandra Nalam <nalamvamsi13@gmail.com>
Fixes a MySQL hang in
airflow db clean --skip-archivewhen a delete fails on a foreign-key constraint.On the failure path,
_do_delete()now rolls back the session before dropping the temporary archive table, and the drop uses the session's active connection instead of checking out a new pooled connection. This prevents metadata-lock contention from leaving the cleanup command stuck indefinitely.Also adds:
Validation:
prek run --from-ref main --stage pre-commitprek run --from-ref main --stage manualairflow-core/tests/unit/utils/test_db_cleanup.pyin Breeze (57 passed, 1 skipped)breeze ci selective-check --commit-ref HEADindicates the shared test utility change expands the CI matrix beyond what was practical to run locallycloses: #66177
Was generative AI tooling used to co-author this PR?
Generated-by: Codex; Claude Code (Fable 5) following the guidelines
Important
🛠️ Maintainer triage note for @Vamsi-klu · by
@potiuk· 2026-07-02 17:46 UTCHelpful heads-up from the maintainers — please address before this PR can be reviewed (see the Pull Request quality criteria):
main. Please rebase onto the latestmainand resolve them.The ball is in your court — you've been assigned to this PR. Fix the above, then mark it Ready for review.
Automated triage — may be imperfect; a maintainer takes the next look.