posting: a dropped UID-warm publish re-arms immediately, so a read-hot and write-hot key loops on a discarded walk
メンテナーはふだん 10 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
posting/mvcc.go の warmCachedUids、tryStartUidWarm、needsUidWarm から始め、次に posting/list.go の publishCalculatedUids を追ってください。TestPublishCalculatedUidsDropsAStaleWalk と、doRollup の試行回数を抑制するパターンを読んでください。繰り返しコミットが発生しても古い walk が無限に再試行されず、読み取りが引き続き正しく、coverage によって制限された動作が検証されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
What
The UID-slice warm added in #9809 discards its work and immediately re-arms when a commit lands mid-walk, so a posting-list key that is both read-hot and write-hot can loop on a walk whose result is always thrown away.
Where
posting/mvcc.go, warmCachedUids:
- A reader elects itself with
tryStartUidWarm, walks a private copy, and callspublishCalculatedUids. publishCalculatedUids(posting/list.go) drops the result whenl.mutationMap.committedUidsTimehas moved since the copy was taken.- The
defer cached.finishUidWarm()then returns the list touidWarmIdle, andisUidsCalculatedon the published list is still false, soneedsUidWarm()is still true and the next reader walks again.
Every commit on a cached key moves committedUidsTime: updateItemInCache calls setMutationAfterCommit(..., refresh=true), which bumps it via x.Max and clears isUidsCalculated/calculatedUids.
TestPublishCalculatedUidsDropsAStaleWalk covers the drop. Nothing bounds the retry.
Cost
Each discarded walk is a full l.iterate, a readListPart Badger read per split for a multi-part list, and a make([]uint64, 0, l.approxLen()).
It is bounded to one walk in flight per key, not one per read: concurrent readers lose the CAS and serve their read unwarmed without walking. So the shape is a single goroutine walking that key continuously and achieving nothing, rather than a per-read tax.
For contrast, before #9809's non-blocking warm the walk held the published list's write lock, which serialized it against the commit path — so the result was always installed and walks per key were bounded by commits. The trade #9809 made was "no commit stall" in exchange for this, and the commit message only described the first half. Worth correcting the record here.
Why it is not a one-liner
Two approaches that look obvious and are not:
- Park the list on a dropped publish (reuse
uidWarmAbandoned). A drop means a commit already landed, and that commit'sCompareAndSwap(uidWarmAbandoned, uidWarmIdle)ran before the park, so nothing re-arms it. A key that stops being committed then stays unwarmed for the life of the cache entry — and an entry with few deltas may never be rolled up and evicted, so "for the life of the entry" can mean indefinitely. - A per-key attempt throttle, the shape
doRollupuses (posting/mvcc.go: amap[uint64]int64ofz.MemHash(key)to last-attempt seconds, skipping anything attempted within 10s). That bounds it correctly and would bound the failure log for free, butdoRollupruns on one goroutine while this would run on every posting read, so the mutex would serialize reads across all keys. It needs sharding or something cheaper.
Not urgent
Reads stay correct throughout — an unwarmed read walks the list in Uids() exactly as it did before the memoization existed. This is wasted work, not a wrong answer.
Introduced in #9809 (b90c1800, perf(posting): warm cached UID slices off the published list's write lock).
- 主要言語
- Go
- スター
- 21.8k
- フォーク
- 1.6k
- 平均マージ
- 11日 7時間
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dgraph-io/dgraph のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 10 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
メンテナーはふだん 10 日以内に返信
-
Stale
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
dgraph-io/dgraph#9811 · コメント 1 件 ·
メンテナーはふだん 10 日以内に返信
-
Stale
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
dgraph-io/dgraph#9810 · コメント 1 件 ·
メンテナーはふだん 10 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 10 日以内に返信
dgraph-io/dgraph の issue をすべて見る
似ている issue
-
enhancement
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
DaoCloud/DaoCloud-docs#7839 ·
メンテナーはふだん 1 日以内に返信
-
Type: Enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
projectdiscovery/urlfinder#167 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
peterstace/simplefeatures#726 ·
-
area: import bug go good first issue priority: low
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
fukubie/StockLlama#69 ·
-
enhancement help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
cloverworks-hq/rumpty-cli#95 ·
メンテナーはふだん 1 日以内に返信