Skip to content

Allow DBDagBag TTL cache eviction without a size cap - #69774

Open
aeroyorch wants to merge 3 commits into
apache:mainfrom
aeroyorch:dbdagbag-ttl-only-cache
Open

Allow DBDagBag TTL cache eviction without a size cap#69774
aeroyorch wants to merge 3 commits into
apache:mainfrom
aeroyorch:dbdagbag-ttl-only-cache

Conversation

@aeroyorch

@aeroyorch aeroyorch commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Allow DBDagBag TTL cache eviction without a size cap (i.e. cache_size=0, cache_ttl>0).

Related to #69001 and #69007

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Claude Opus 4.8 to analyze the impact of this change in terms of docs/code.


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {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.

@aeroyorch
aeroyorch requested review from XD-DENG and ashb as code owners July 12, 2026 12:04
@aeroyorch
aeroyorch force-pushed the dbdagbag-ttl-only-cache branch 2 times, most recently from 379aa9e to a112469 Compare July 12, 2026 12:12
@aeroyorch aeroyorch changed the title Allow DBDagBag TTL cache eviction without a size cap Allow DBDagBag TTL cache eviction without a size cap Jul 12, 2026

@SameerMesiah97 SameerMesiah97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just one nit. Looks good otherwise.

Comment thread airflow-core/src/airflow/models/dagbag.py Outdated
@aeroyorch

Copy link
Copy Markdown
Contributor Author

Just one nit. Looks good otherwise.

Thanks for the review! Changes already implemented

@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Jul 15, 2026
@jason810496
jason810496 self-requested a review July 16, 2026 13:03
@aeroyorch
aeroyorch requested a review from SameerMesiah97 July 18, 2026 09:53
@lohyenshen

Copy link
Copy Markdown

hi, may I know what airflow version would this be released to?

@aeroyorch
aeroyorch force-pushed the dbdagbag-ttl-only-cache branch from 5b5ca6c to d65c199 Compare July 25, 2026 15:24

@vatsrahul1001 vatsrahul1001 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The DBDagBag fix itself looks right, but I don't think it's reachable from the actual config path yet. create_dag_bag() in api_fastapi/common/dagbag.py still does:

if cache_size <= 0:
    return DBDagBag(cache_size=0)

That early-return fires whenever dag_cache_size <= 0 and never even reads cache_ttl_config, so setting dag_cache_size = 0 + dag_cache_ttl = 3600 in airflow.cfg still ends up as a plain unbounded dict with no eviction. test_create_dag_bag_cache_modes still asserts exactly that (the "size_zero_unbounded" case expects dict/_use_cache=False for cache_size=0, cache_ttl=3600), and config.yml's dag_cache_size description still says 0 means "unbounded dict, no eviction" with no mention of TTL-only mode.

Could you also update create_dag_bag() to pass cache_ttl through when cache_size<=0, add a case to test_create_dag_bag_cache_modes covering that combo, and touch up the config.yml wording? Otherwise this fix isn't actually reachable by anyone configuring it through airflow.cfg.

@aeroyorch
aeroyorch force-pushed the dbdagbag-ttl-only-cache branch from 45641ab to 68f1a7a Compare August 2, 2026 10:40
@aeroyorch
aeroyorch force-pushed the dbdagbag-ttl-only-cache branch from 68f1a7a to 2432fa4 Compare August 2, 2026 10:43
@aeroyorch

aeroyorch commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

The DBDagBag fix itself looks right, but I don't think it's reachable from the actual config path yet. create_dag_bag() in api_fastapi/common/dagbag.py still does:

if cache_size <= 0:
    return DBDagBag(cache_size=0)

That early-return fires whenever dag_cache_size <= 0 and never even reads cache_ttl_config, so setting dag_cache_size = 0 + dag_cache_ttl = 3600 in airflow.cfg still ends up as a plain unbounded dict with no eviction. test_create_dag_bag_cache_modes still asserts exactly that (the "size_zero_unbounded" case expects dict/_use_cache=False for cache_size=0, cache_ttl=3600), and config.yml's dag_cache_size description still says 0 means "unbounded dict, no eviction" with no mention of TTL-only mode.

Could you also update create_dag_bag() to pass cache_ttl through when cache_size<=0, add a case to test_create_dag_bag_cache_modes covering that combo, and touch up the config.yml wording? Otherwise this fix isn't actually reachable by anyone configuring it through airflow.cfg.

Thanks for the review. Changes already implemented :)

@aeroyorch
aeroyorch requested a review from vatsrahul1001 August 3, 2026 08:01
@eladkal eladkal added this to the Airflow 3.3.1 milestone Aug 4, 2026
@eladkal eladkal added type:bug-fix Changelog: Bug Fixes backport-to-v3-3-test Backport to v3-3-test labels Aug 4, 2026
@vatsrahul1001

vatsrahul1001 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

LGTM!, can be merged after code owners review

@vatsrahul1001

Copy link
Copy Markdown
Contributor

Moving to 3.3.2 as this is still pending code owner review and do not want to rush on merging this as it not critical

@aeroyorch

Copy link
Copy Markdown
Contributor Author

Moving to 3.3.2 as this is still pending code owner review and do not want to rush on merging this as it not critical

No problem. In the meantime, I can work on some of the other items to fix #69001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-v3-3-test Backport to v3-3-test ready for maintainer review Set after triaging when all criteria pass. type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants