Fix memory growth from pathlib sys.intern in long-running processes#65706
Merged
potiuk merged 3 commits intoapache:mainfrom Apr 25, 2026
Merged
Fix memory growth from pathlib sys.intern in long-running processes#65706potiuk merged 3 commits intoapache:mainfrom
potiuk merged 3 commits intoapache:mainfrom
Conversation
c4677f0 to
02e4ed3
Compare
02e4ed3 to
26eb945
Compare
Member
|
This is COOL. Thanks @wjddn279 ! |
potiuk
approved these changes
Apr 25, 2026
Contributor
|
Hi maintainer, this PR was merged without a milestone set.
|
Contributor
Backport successfully created: v3-2-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
github-actions Bot
pushed a commit
to aws-mwaa/upstream-to-airflow
that referenced
this pull request
Apr 25, 2026
… processes (apache#65706) * Fix memory growth from pathlib sys.intern in long-running processes * fix supporting python version * fix logic (cherry picked from commit d14862c) Co-authored-by: Jeongwoo Do <48639483+wjddn279@users.noreply.github.com>
aws-airflow-bot
pushed a commit
to aws-mwaa/upstream-to-airflow
that referenced
this pull request
Apr 25, 2026
… processes (apache#65706) * Fix memory growth from pathlib sys.intern in long-running processes * fix supporting python version * fix logic (cherry picked from commit d14862c) Co-authored-by: Jeongwoo Do <48639483+wjddn279@users.noreply.github.com>
1 task
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.
Problem?
After patching for #65121, I found the memory growth in
parsed = [sys.intern(str(x)) for x in rel.split(sep) if x and x != '.']statement in python Path library.memray-flamegraph-output-2026-04-12.13.14.12.556546.html
Cause?
pathlib.PurePath._parse_pathcallssys.internon every path component. In long-running Airflow processes (scheduler, dag-processor, triggerer, workers) each task run produces log paths containing unique identifiers (dag_id, run_id, task_id, try_number), and those interned components accumulate in the interpreter's intern dict for the lifetime of the process.Solution?
The exactly same issue was reported in python issue (python/cpython#119518). Python 3.14 removes the interning call from _parse_path entirely (python/cpython#123356), but Airflow supports earlier versions. This PR backports the 3.14 parsing logic as a small Path subclass (_PatchedPath) and routes log-folder/log-file initialization through it, so path components can be garbage-collected as ordinary mortal strings.
After applying this change and #65121, I confirmed that all memory leaks under the local executor are gone. This improvement should also carry over to other components that rely on logging (e.g. dag-processor, celery executor).
memray-flamegraph-output-2026-04-17 08:12:02.069120.html
Was generative AI tooling used to co-author 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.