Content cache ignores the query string, so one path serves the response cached for another query
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
まず AsyncContentCache と CacheKeys.path / CacheKeys.method を読み、キャッシュキーの動作に関する既存のユニットテストを確認します。同じパスに2つのクエリ文字列を付けて送信し、それぞれに個別のレスポンスが返ることを確認するユニットテストを追加します。2つ目のレスポンスが1つ目のクエリのキャッシュエントリから返されなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
Version
pulpcore 3.120.0, also on main; CACHE_ENABLED = True.
Describe the bug
AsyncContentCache keys its entries on the request path and method only
(CacheKeys.path, CacheKeys.method); the query string is not part of the key. The
content app's answer can depend on the query string, though: pull-through caching
passes the request to Remote.get_remote_artifact_url(), and pulp_python takes the
upstream URL from its redirect parameter. Two requests for one path that differ only
in the query string share a cache entry, and the second is answered with whatever the
first one cached, until the entry expires.
What we saw
pulp_python 3.36.2, a pull-through distribution backed by a repository. Two CI jobs
installed the same package, not cached yet, within about a second of each other. From
the content app's access log, all four requests for the same path
.../uv-0.11.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
| client | query | response | |
|---|---|---|---|
| 1 | job A | redirect=<upstream>.whl.metadata |
200, metadata (12 kB) |
| 2 | job A | redirect=<upstream>.whl |
200, the wheel (25 MB), saved |
| 3 | job B | redirect=<upstream>.whl.metadata |
200, metadata (12 kB) |
| 4 | job B | redirect=<upstream>.whl |
200, 12 kB, in 67 ms |
Request 4 got the metadata that request 3 had put into the cache under the wheel's
path, and pip failed with THESE PACKAGES DO NOT MATCH THE HASHES. A few minutes later
the same link served the wheel again. The .metadata lands in the query string because
pip builds the PEP 658 URL by appending .metadata to the whole link.
To Reproduce
The interleaving above depends on timing. The key itself can be shown directly: wrap a
handler that answers with its query string in AsyncContentCache and request one path
with two query strings; the second request is a cache hit with the first one's answer.
Expected behavior
A request is never answered with an entry cached for a different query string.
Additional context
Adding the query string to the default keys of AsyncContentCache fixes it; a change
with a unit test is on
https://github.com/AVSystem/pulpcore/tree/fix-cache-key-query-string, and we can open
it as a pull request if this is the direction you want. Requests without a query string
keep one entry each, so ordinary content is cached as before; requests carrying a
per-request value in the query (a signed URL) would get an entry each.
pulp_python has its own part in this (a pull-through link announces metadata that pip
then asks for at the package's path), which we are reporting there.
- 主要言語
- Python
- スター
- 619
- フォーク
- 176
- 平均マージ
- 16時間 49分
- マージ済み PR(30日)
- 126
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pulp/pulpcore のほかの issue
-
Issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
Feature
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
pulp/pulpcore#5802 · コメント 10 件 ·
メンテナーはふだん 1 日以内に返信
-
Issue Triage-Needed
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
Issue
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
メンテナーはふだん 1 日以内に返信
-
Issue
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
enhancement help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Git-Hospital/githealthcheck#61 ·
メンテナーはふだん 1 日以内に返信
-
changelog investigate
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
ramnes/notion-sdk-py#433 ·
-
Partial method descriptors raise on class access対応中かも @Gambit-Checkmate が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 19 日以内に返信
-
docs pkg:core
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
pydantic/pydantic-ai#11929 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
intake/intake-esm#789 ·