TestMetricTxnAborts is racy: baseline fetchMetrics is not retried while the assertion is
メンテナーはふだん 10 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 静か
- 技術スタック
- go
- 領域
- testing-qa
調査の方向性
dgraph/cmd/alpha/metrics_test.go の TestMetricTxnAborts から始め、その baseline fetchMetrics 呼び出しを retryableFetchMetrics と比較します。関連する TestMetricTxnCommits と TestMetricTxnDiscards のケースについても、同じパターンになっているか確認します。メトリクスのベースラインが非同期エクスポートを許容し、影響を受けるテストがメトリクス欠落による race なしでパスすれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
TestMetricTxnAborts reads its baseline metric value with an unretried fetchMetrics, while the assertion that follows uses retryableFetchMetrics. Prometheus metric export is asynchronous, so the baseline read can land before dgraph_txn_aborts_total has been published and the test fails with a message that reads like a missing metric rather than a race.
The code
dgraph/cmd/alpha/metrics_test.go:
func TestMetricTxnAborts(t *testing.T) {
metricName := "dgraph_txn_aborts_total"
...
require.NoError(t, commitWithTs(mr1, false))
require.Error(t, commitWithTs(mr2, false))
metrics := fetchMetrics(t, metricName) // <-- not retried
... second round of mutations ...
require.NoError(t, retryableFetchMetrics(t, map[string]int{
metricName: metrics[metricName] + 1, // <-- retried
}))
}
The asymmetry looks unintentional: the same value is fetched twice, once without tolerance for propagation delay and once with.
Note also that dgraph_txn_aborts_total does not exist on the /metrics endpoint until the first abort is actually exported, so on a fresh cluster the baseline read is the most likely of the two to race — it is the one that has to wait for the counter to appear at all, not merely to increment.
Observed failure
--- FAIL: TestMetricTxnAborts (0.02s)
metrics_test.go:153: the required metric 'dgraph_txn_aborts_total' was not found
Line 153 is inside fetchMetrics, reached from the unretried call. It passes on re-run, which is consistent with a propagation race rather than a functional problem. The preceding require.Error(t, commitWithTs(mr2, false)) passes, so the aborting commit did happen.
Seen once in CI on a fork of this repo; green on re-run of the same commit.
Suggested fix
Use the retrying variant for the baseline too, so the test tolerates propagation in both reads:
require.NoError(t, retryableFetchMetrics(t, map[string]int{metricName: 1}))
metrics := fetchMetrics(t, metricName)
Or have fetchMetrics treat "metric absent" as retryable when the caller is establishing a baseline. Either way the intent is that the test waits for the counter to exist before reading it.
TestMetricTxnCommits and TestMetricTxnDiscards have the same shape and are presumably exposed to the same race, though we have only observed the aborts variant failing.
I'm happy to open a PR for this if it's welcome.
- 主要言語
- 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時間 初心者へのやさしさ 84/100
dgraph-io/dgraph#9810 · コメント 1 件 ·
メンテナーはふだん 10 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 10 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/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 日以内に返信