Repository navigation
Make airflow standalone discover new Dag files within seconds - #74479
Merged
Merged
Conversation
A Dag file added after startup is only found when its bundle refreshes, and [dag_processor] refresh_interval defaults to 300 seconds, so under airflow standalone a new file took up to five minutes to show up. Standalone now passes its components a refresh_interval equal to [dag_processor] bundle_refresh_check_interval (5 seconds by default), so the Dags folder is rescanned each time the Dag processor checks whether a bundle is due. It does this only while refresh_interval and dag_bundle_config_list are at their defaults and the interval is not set in the environment, so an explicit choice wins and remote bundles keep their fetch cadence.
kaxil
marked this pull request as ready for review
October 8, 2026 23:08
kaxil
requested review from
bugraoz93,
dheerajturaga,
henry3260 and
potiuk
as code owners
October 8, 2026 23:08
ashb
approved these changes
Oct 9, 2026
dheerajturaga
approved these changes
Oct 9, 2026
dheerajturaga
left a comment
Member
There was a problem hiding this comment.
We modified the refresh interval in our dev env to be quicker. This is definitely needed out of the box
Member
|
Indeed :) |
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.
With
airflow standalone, a Dag file added after startup takes up to five minutes to show up. The Dag processor only lists a bundle's files when that bundle refreshes, and[dag_processor] refresh_intervaldefaults to 300 seconds, the value #45722 carried over from[scheduler] dag_dir_list_interval.min_file_process_intervaldoes not help: it only re-parses files the processor already knows about. Standalone is the quick-start and local development path, where the loop is "write a Dag file, look for it in the UI", so a five-minute wait looks like the file was not picked up at all.Standalone now starts its components with
refresh_intervalset to[dag_processor] bundle_refresh_check_interval(5 seconds by default) and says so at startup:Nothing changes outside
airflow standalone.Measured in a breeze container (SQLite, examples off): start standalone, wait for the Dag processor's first scan, write a minimal Dag file, then poll
airflow dags list -o jsonevery 2 seconds until the Dag appears.mainMost of the remaining 9 seconds is the poller: one
airflow dags listcall takes about 3.5 seconds in that container. In both runs the Dag processor's next scan came within 5 seconds of the file being written.Why
bundle_refresh_check_intervalrather than a fixed number. The processor only checks whether a bundle is due that often, so a lowerrefresh_intervalchanges nothing and a higher one only adds waiting. Refreshing the default Dags folder costs a directory walk, a read of each candidate file for the safe-modeairflow/dagcheck, and a few metadata queries;LocalDagBundle.refresh()itself does nothing.Why only when the defaults are untouched. An explicit choice wins. The override is skipped when
AIRFLOW__DAG_PROCESSOR__REFRESH_INTERVALis set (to any value), whenrefresh_intervalinairflow.cfgdiffers from the default, or whendag_bundle_config_listis anything other than the default Dags folder. That last condition matters because refreshing a remote bundle such asGitDagBundlefetches from the remote, and standalone should not turn that into a fetch every 5 seconds. Theairflow.cfgcheck compares with the default instead of asking whether the option is set, because theairflow.cfgAirflow generates on first run writes every default as a live line,refresh_interval = 300included. The cost: a hand-writtenrefresh_interval = 300inairflow.cfglooks the same as the generated file and gets the standalone value. Setting it through the environment keeps it.Watching the Dags folder for file events would remove the polling delay altogether. That is a larger change to the Dag processor and is not part of this PR.
{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.