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

Fix broken dagrun links when many runs start at the same time #23462

Merged
merged 2 commits into from
May 9, 2022

Conversation

repl-chris
Copy link
Contributor

DagRun links in the UI to /graph can currently be broken if you have several runs starting at (basically) the same time. The UI control that airflow uses for base_date only has per-second resolution (it loses everything sub-second), so to account for that the current implementation defaults base_date to exec_date rounded up to the nearest second. The problem occurs when several other dagruns were triggered in that rounded second - those other dagruns are loaded first (up to num_runs) so it's possible the requested dagrun does not even get loaded. I know it sounds like an uncommon scenario but it actually happens to us a lot, as we have several processes that kick off many dagruns at the same time.

This PR maintains the existing rounding behavior for the base_date UI control, but uses the requested exec_date for the database query when the base_date has been rounded. This way the requested dagrun will always be the first record returned, even when base_date has been rounded up.


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, 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 newsfragement file, named {pr_number}.significant.rst, in newsfragments.

@boring-cyborg boring-cyborg bot added the area:webserver Webserver related Issues label May 3, 2022
Copy link
Contributor

@o-nikolas o-nikolas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice first commit and great testing! Unfortunately I'm not a committer so I can't trigger CI to run for you.

@repl-chris
Copy link
Contributor Author

FYI @ryanahamilton @ashb @bbovenzi this is ready for re-review. Apologies for the static-checks failures, should be good to go now

@bbovenzi
Copy link
Contributor

bbovenzi commented May 6, 2022

@repl-chris Do you mind updating the branch to the latest on main? I think that could solve the failing checks

@repl-chris
Copy link
Contributor Author

@repl-chris Do you mind updating the branch to the latest on main? I think that could solve the failing checks

@bbovenzi ok, I have rebased it on latest main, thanks!

Copy link
Contributor

@bbovenzi bbovenzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work!

@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 May 8, 2022
@github-actions
Copy link

github-actions bot commented May 8, 2022

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.

@bbovenzi bbovenzi added this to the Airflow 2.3.1 milestone May 8, 2022
@bbovenzi
Copy link
Contributor

bbovenzi commented May 8, 2022

@repl-chris Sorry, but I think you need to update the branch again

@repl-chris
Copy link
Contributor Author

@bbovenzi no worries...updated again :)

@bbovenzi bbovenzi merged commit 8280167 into apache:main May 9, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented May 9, 2022

Awesome work, congrats on your first merged pull request!

@repl-chris repl-chris deleted the GraphFilterBreaksLinks branch May 9, 2022 20:55
@ephraimbuddy ephraimbuddy added the type:bug-fix Changelog: Bug Fixes label May 17, 2022
ephraimbuddy pushed a commit that referenced this pull request May 17, 2022
* Load requested dagrun even when there are many dagruns at (almost) the same time

* Fix code formatting issues

(cherry picked from commit 8280167)
ephraimbuddy pushed a commit that referenced this pull request May 21, 2022
* Load requested dagrun even when there are many dagruns at (almost) the same time

* Fix code formatting issues

(cherry picked from commit 8280167)
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 type:bug-fix Changelog: Bug Fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants