A cached PR overlay is served after the index it was classified against moved
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
調査の方向性
Start with load_pr_overlay and load_posted_overlay in server/code/app/index/pr_overlay.py, then read the unit-test fakes in tests/unit/test_pr_post_image.py. Trace how the cache keys represent the indexed commit, branch tip, path scope, diff cut and posted overlay SHAs; add cases that change each input between reads. Done means those changes cause cache misses and the tests confirm the refreshed classifications and diff.
索引モデルが issue の本文から書いたものです。
説明
Company
Independent
Component
Code index
Describe what's wrong
A reindex within 60 s of a PR read leaves the PR overlay's classification at the old index.
load_pr_overlay (server/code/app/index/pr_overlay.py) keeps its result for code_pr_overlay_cache_ttl_s (60 s) under (mirror, namespace, PR number) and accepts a hit when the PR head sha matches. The overlay classifies each function added, modified or unchanged, and binds each call site, against the name table at the namespace's indexed commit, and the key does not hold that commit. A PR read once, then reindexed to a commit that defines a function the PR adds, still reports that function as added for the rest of the TTL, with its call sites bound against the old names. code.callers, code.callees, code.impact and code.review_brief (through its impact read) all answer from it.
The diff is the PR head against merge-base(head, refs/heads/<branch>), and the key does not hold the branch tip either. When the branch gains commits the PR head already contains (a base merged by merge commit or fast-forward, or by a rebase that reuses shas), the merge-base moves and the diff shrinks, and a hit still serves the old diff.
Three more inputs of the overlay are missing from the key: the target branch, the path scope (path_prefixes) and the diff cut (diff_max_bytes). No caller varies them for one namespace today, since overlay_for_namespace passes the namespace's own git_branch, its path_prefixes and the default cut, so they are a gap in the key's completeness: they bite a direct caller, a repository-entry edit inside the TTL, or any namespace that holds several branches.
load_posted_overlay has the same shape for a post-image sent with the request: the key holds the PR number and the content digest only, so a re-send of the same files after an index move is served the old classification, and a re-send with another pr_head_sha or pr_base_sha keeps the first one's overlay_head_sha label.
The other caches in the module are keyed correctly. _FILE_FACTS is keyed on path and content digest, _FILE_EDGES on path, content digest and the digest of the name-table rows the file's names bind to, and _NAMES on namespace, indexed commit and name. _RUNNING holds an in-flight parse, not a result.
Does it reproduce on the latest release or main?
Yes
How to reproduce
On main at 3058a5816, with the unit-test fakes of tests/unit/test_pr_post_image.py (no server, no ClickHouse):
- A namespace whose indexed commit does not define
loadDataParts; read a PR that adds it withload_pr_overlay. Move the namespace'sgit_headstate to a commit that defines it and read again. The second call still reports itadded. - The same call twice with the target branch's tip moved between them, and its merge-base with the PR head. The second call returns the overlay of the old merge-base.
- One mirror, one PR head.
load_pr_overlay(..., branch="master")and thenload_pr_overlay(..., branch="release")for the same namespace and PR. The second call returns the first call's overlay (itsbase_sha, its diff, itsmodifiedset). Swapping the order swaps the wrong answer. - The same call with
path_prefixes=("src/",)and then("lib/",). The second returns the first's symbols.
Expected behavior
An overlay is served from the cache only for the inputs it was built from: the PR head, the target branch's tip, the namespace's indexed commit, the path scope and the diff cut. Any of them changing is a miss, as a pushed PR head already is.
Environment
main at 3058a5816, Python 3.12, unit tests only.
Related issues and pull requests
Related: https://github.com/ClickHouse/loom/issues/1680
How this was found
An AI tool helped find it, and I reproduced it myself
Additional context
The cache holds a namespace in its key since an earlier fix, so two namespaces on one mirror (one per branch) do not share an overlay today. A design that indexes several branches in one namespace (#1680) makes the target branch an input of every overlay read, which is why the key should hold every input first.
Redaction
- I removed tokens, keys, passwords and personal or customer data from everything above.
- 主要言語
- Python
- スター
- 221
- フォーク
- 35
- 平均マージ
- 14時間 21分
- マージ済み PR(30日)
- 873
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ClickHouse/loom のほかの issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 76/100
ClickHouse/loom#2014 ·
メンテナーはふだん 1 日以内に返信
-
Options of loom period-digest, reextract, reconcile-status and demote-activity-narration print no help text対応中かも @VanshajPoonia が今日担当しました。 オープンbug good first issue help wanted up-for-grabs
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
ClickHouse/loom#1988 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
A compiler-tier checkout fetch from a shallow mirror never records its head対応中かも @KaloyanNaumov が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
ClickHouse/loom#2016 ·
メンテナーはふだん 1 日以内に返信
-
Delta workers fetch the compiler-tier checkout under a hard-coded 600 s limit対応中かも @KaloyanNaumov が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 35/100
ClickHouse/loom#2012 ·
メンテナーはふだん 1 日以内に返信
-
loom participant retire cannot retire an orphaned participant after container replacement or host reboot対応中かも @l0K1ngg が今日担当しました。 オープンbug help wanted up-for-grabs
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
ClickHouse/loom#2007 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
ClickHouse/loom の issue をすべて見る
似ている issue
-
DMB documentation good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ubuntu/ubuntu-project-docs#921 ·
メンテナーはふだん 1 日以内に返信
-
⏳ Pending feedback 🐛 Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
jumpserver/jumpserver#18282 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
accepted
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
future-agi/future-agi#5274 ·
メンテナーはふだん 1 日以内に返信
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
GenericMappingTools/pygmt#5014 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信