Skip to content

Downloader: ensure refresh_knowledge thread are properly closed#18709

Open
glyh wants to merge 2 commits intocompatiblefrom
lyh/fix-dangling-downloader-thread-memleak
Open

Downloader: ensure refresh_knowledge thread are properly closed#18709
glyh wants to merge 2 commits intocompatiblefrom
lyh/fix-dangling-downloader-thread-memleak

Conversation

@glyh
Copy link
Copy Markdown
Member

@glyh glyh commented Apr 1, 2026

Summary

Each peer tracked by the Downloader spawns a refresh_knowledge async thread that periodically polls for downloadable jobs. This thread was previously stopped only when the peer was forgotten (via the finished ivar). However, the thread held no reference to the top-level stop deferred, so if the downloader was shut down while peers were still active, these threads would remain alive indefinitely — leaking async jobs and memory.

Fix

refresh_knowledge now derives its internal stop as Deferred.any [ forgot_peer; stop ], combining the per-peer termination signal with the downloader-level shutdown signal. The thread now terminates on whichever comes first.

@glyh glyh changed the title Downloader: ensure all threads are properly closed Downloader: ensure refresh_knowledge thread are properly closed Apr 1, 2026
@glyh glyh added the bugfix label Apr 1, 2026
@glyh
Copy link
Copy Markdown
Member Author

glyh commented Apr 7, 2026

!ci-build-me

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

Labels

Projects

Status: To triage

Development

Successfully merging this pull request may close these issues.

1 participant