A cached PR overlay is served after the index it was classified against moved
维护者通常 1 天内回复
评估
调研方向
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 分钟
- 30 天内合并 PR
- 873
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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 天内回复
相似的 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 天内回复