Skip to content

Limit downloader memory retention#1

Merged
adulau merged 1 commit into
mainfrom
codex/review-csaf_downloader-for-memory-leaks
Jul 7, 2026
Merged

Limit downloader memory retention#1
adulau merged 1 commit into
mainfrom
codex/review-csaf_downloader-for-memory-leaks

Conversation

@adulau

@adulau adulau commented Jul 7, 2026

Copy link
Copy Markdown
Member

Motivation

  • Prevent unbounded memory retention by workers that reused a single bytes.Buffer across many advisory downloads, which can keep large backing arrays live for the lifetime of the worker.
  • Ensure HTTP response bodies are always closed on non-OK responses to avoid holding network resources and readers open during error paths.

Description

  • Removed the long-lived data bytes.Buffer from downloadContext and allocate a per-advisory var data bytes.Buffer inside downloadAdvisory, and updated uses (signature check, forwarding, and file writes) to use the local buffer instead of dc.data.
  • Closed response bodies on non-OK responses when loading OpenPGP keys in loadOpenPGPKeys, when fetching changes.csv in loadChanges, and when loading ROLIE feeds in processROLIE to avoid leaking body readers.
  • Changes touch cmd/csaf_downloader/downloader.go (main memory/buffer change and small cleanup) and csaf/advisories.go (response-body close fixes and ordering).

Testing

  • Ran go test ./cmd/csaf_downloader -run TestShaMarking, which passed.
  • Ran go test ./cmd/csaf_downloader ./csaf, where ./csaf package tests passed and cmd/csaf_downloader failed due to an existing TestStoreFailedAdvisory expectation (expected to fail with an error).
  • Ran full test suite go test ./..., which showed the same failure only in cmd/csaf_downloader and all other packages passed.

Codex Task

@adulau adulau merged commit 59026cb into main Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant