Fix DagFileProcessorManager silent hang on DB lock contention#68118
Open
Subham-KRLX wants to merge 2 commits into
Open
Fix DagFileProcessorManager silent hang on DB lock contention#68118Subham-KRLX wants to merge 2 commits into
Subham-KRLX wants to merge 2 commits into
Conversation
77d3f99 to
7b665dd
Compare
jscheffl
reviewed
Jun 6, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent the DagFileProcessorManager main loop from silently hanging during startup when DB lock contention blocks the deactivate_stale_dags / deactivate_deleted_dags update paths, by applying a per-session lock wait timeout and gracefully skipping the iteration on lock-timeout errors.
Changes:
- Added a
with_db_lock_timeout()SQLAlchemy utility to apply per-dialect lock wait timeouts (PostgreSQL/MySQL). - Wrapped
deactivate_stale_dags()anddeactivate_deleted_dags()DB updates with the lock-timeout context manager and added rollback + warning on lock-timeoutOperationalError. - Added a unit test covering lock-timeout handling for
deactivate_stale_dags().
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| airflow-core/src/airflow/utils/sqlalchemy.py | Adds with_db_lock_timeout() context manager to apply DB lock wait timeouts. |
| airflow-core/src/airflow/dag_processing/manager.py | Uses the lock-timeout wrapper and handles lock-timeout errors to avoid processor hangs. |
| airflow-core/tests/unit/dag_processing/test_manager.py | Adds a regression test for lock-timeout handling in deactivate_stale_dags(). |
7b665dd to
1611f16
Compare
ephraimbuddy
reviewed
Jun 6, 2026
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.
Instead of risky thread-based heartbeats this PR adds a native
with_db_lock_timeoutcontext manager to the blockingdeactivate_stale_dagsanddeactivate_deleted_dagsupdates. If a lock timeout occurs it safely rolls back logs a warning and skips the iteration so the main loop andheartbeat()can continue uninterrupted.closes: #68101
Was generative AI tooling used to co-author this PR?