Creating a repository version from a large base_version uses excessive memory (can OOM the worker)
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 18/100
調査の方向性
Start with RepositoryVersion.add_content in pulpcore/app/models/repository.py, where the RepositoryContent list is built and passed to bulk_create without a batch size, and check how new_version(base_version=...) calls it. Linked pull request #1721 is already open against this work, so read it and its discussion before starting. Done means the copy builds and inserts RepositoryContent in bounded chunks, so peak memory does not grow with the number of content units.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
Creating a new RepositoryVersion from a base_version that contains a large number of content units (~2M) consumes several GB of RAM in a single task and can get the worker OOM-killed (observed as container exit code 137 against an 8 GiB limit).
Root cause
RepositoryVersion.new_version(base_version=…) resolves the copy into a single add_content() call with the entire base content set. In RepositoryVersion.add_content (pulpcore/app/models/repository.py):
- all content pks are materialized into a Python
set; - a Python list with one
RepositoryContentinstance per unit is built (~2M objects); RepositoryContent.objects.bulk_create(repo_content)is called with nobatch_size.
The per-instance list dominates (~1.5–3 GB for ~2M units at ~0.7–1.5 KB/instance), and the unbounded bulk_create adds a large transient on top (Django/psycopg build the full INSERT while the list is still alive). Peak scales linearly with repo size, so sufficiently large repositories cannot be copied on a memory-constrained worker.
To Reproduce
- Create a repository whose latest version holds ~1–2M content units (any plugin, e.g.
pulp_file). - Create a second repository and create a new version from the first via
base_version(e.g. themodify/endpoint withbase_version, ornew_version(base_version=…)directly). - Watch worker RSS climb to multiple GB; on a memory-limited worker the task fails with the worker going missing (OOM kill).
Expected behavior
Copying a large base_version should complete with bounded memory, independent (or nearly so) of the number of content units.
Proposed fix
Chunk the RepositoryContent construction + insert in add_content() in explicit batches. Note that bulk_create(objs, batch_size=N) alone is not sufficient, because Django does list(objs) internally before chunking the SQL — the calls themselves must be chunked to bound Python-object memory. A fully DB-side INSERT … SELECT copy path for base_version would make memory independent of size but needs to handle pulp_id/timestamp generation server-side.
- 主要言語
- Python
- スター
- 641
- フォーク
- 178
- 平均マージ
- 17時間 36分
- マージ済み PR(30日)
- 76
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pulp/pulpcore のほかの issue
-
Content cache ignores the query string, so one path serves the response cached for another queryオープンTriage-Needed
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
Issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
Feature
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
pulp/pulpcore#5802 · コメント 10 件 ·
メンテナーはふだん 1 日以内に返信
-
Feature Triage-Needed
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
-
Redis client has no socket timeouts, so a lost Redis connection stalls content requests for minutesオープンIssue Triage-Needed
難易度 3/5 半日 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
bug bugfix
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
simplify
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
drevendev/Devostasis#158 · コメント 1 件 ·
-
Elko Super TR: temperature stops updating once the thermostat reports its active sensor対応中かも @zigpy-review-bot が今日担当しました。 オープンbot: code audit
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
zigpy/zha-device-handlers#5790 ·
メンテナーはふだん 1 日以内に返信
-
source defect
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
mampfes/hacs_waste_collection_schedule#8269 ·
メンテナーはふだん 1 日以内に返信