Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rescue if a DagRun's DAG was removed from db #17544

Merged

Conversation

uranusjr
Copy link
Member

Fix #17442.

The exception happens when a DAG is removed from the database (via web UI or something else), but there are still unfinished runs associated to it. This catches the scenario and use the existing fallback setting max_active_runs to zero.

@boring-cyborg boring-cyborg bot added the area:webserver Webserver related Issues label Aug 11, 2021
@ephraimbuddy ephraimbuddy added this to the Airflow 2.1.3 milestone Aug 11, 2021
@github-actions
Copy link

The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest main or amend the last commit of the PR, and push it with --force-with-lease.

@github-actions github-actions bot added the okay to merge It's ok to merge this PR as it does not require more tests label Aug 11, 2021
@jedcunningham
Copy link
Member

Should we add a test for this as well?

@uranusjr
Copy link
Member Author

Good point, I'll add one (and fix the typo in the commit message 🤦‍♂️)

@uranusjr
Copy link
Member Author

Writing a proper test turns out to be a long journey figuring out a right combination to trigger this bug. So to trigger this bug, a DAG should not be in the DagBag, but in the DagModel table, but not in the SerializedDagModel table.

@georborodin Does the DAG you deleted from the web UI have subdags? This is the only situation I’ve managed to set up a proper environment for the test. (Although I wouldn’t be surprised if there’s more I couldn’t locate.)

@uranusjr uranusjr force-pushed the dont-raise-when-get-dag-cant-find-serialized-dag branch from cd47635 to d7a94c5 Compare August 12, 2021 11:09
@uranusjr uranusjr changed the title Rescure if a DagRun's DAG was removed from db Rescue if a DagRun's DAG was removed from db Aug 12, 2021
@kaxil kaxil merged commit 60ddcd1 into apache:main Aug 12, 2021
@uranusjr uranusjr deleted the dont-raise-when-get-dag-cant-find-serialized-dag branch August 13, 2021 07:10
@uranusjr
Copy link
Member Author

For future reference, the complete steps to reproduce this from the web UI is:

  1. Create a DAG with a subDAG that runs for a long-ish time. Wait for them to show up in the web UI.
  2. Run the DAG (thus trigging the subDAG).
  3. delete the parent DAG from the web UI. (This does not delete the subDAG.)
  4. Try to block the subDAG’s unfinished run from step 2. (Should fail with SerializedDagNotFound before this patch.)

jhtimmins pushed a commit that referenced this pull request Aug 13, 2021
Fix #17442.

The exception happens when a DAG is removed from the database (via web UI or something else), but there are still unfinished runs associated to it. This catches the scenario and use the existing fallback setting `max_active_runs` to zero.

(cherry picked from commit 60ddcd1)
kaxil pushed a commit that referenced this pull request Aug 17, 2021
Fix #17442.

The exception happens when a DAG is removed from the database (via web UI or something else), but there are still unfinished runs associated to it. This catches the scenario and use the existing fallback setting `max_active_runs` to zero.

(cherry picked from commit 60ddcd1)
jhtimmins pushed a commit that referenced this pull request Aug 17, 2021
Fix #17442.

The exception happens when a DAG is removed from the database (via web UI or something else), but there are still unfinished runs associated to it. This catches the scenario and use the existing fallback setting `max_active_runs` to zero.

(cherry picked from commit 60ddcd1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:webserver Webserver related Issues okay to merge It's ok to merge this PR as it does not require more tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deleted DAG raises SerializedDagNotFound exception when accessing webserver
4 participants