Race in gateway/apps tests: scanner.New called concurrently from parallel tests
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 84/100
調査の方向性
internal/gateway/apps/ai_secrets_test.go、特に secretsFixture を読み、並列テストがどのように scanner を取得しているか確認してください。issue では sync.OnceValues を使ってパッケージごとに1つの scanner を共有することを提案しています。説明どおり Scanner が並行使用に対応しているか確認してください。go test -race ./internal/gateway/apps を繰り返し実行し、race が発生しなくなったことを確認してください。
索引モデルが issue の本文から書いたものです。
説明
go test -race ./internal/gateway/apps fails now and then with DATA RACE in tests that have nothing in common, such as TestExplainOfAHealthyAppIsRefused, TestTemplateListCarriesMaxSharing and TestNonMemberCannotCreate. Locally it failed 2 of 7 runs. CI has been green, so it may only show up under load.
The race is two goroutines writing viper's global config:
Write at ... by goroutine 61:
github.com/spf13/viper.(*Viper).SetConfigType() [email protected]/viper.go:2189
github.com/zricethezav/gitleaks/v8/detect.NewDetectorDefaultConfig() detect.go:136
github.com/nebari-dev/javo/internal/ai/redact/scanner.New() scanner.go:32
.../gateway/apps_test.secretsFixture() ai_secrets_test.go:22
.../gateway/apps_test.TestInjectedLogTextChangesNothing() ai_injection_test.go:20
Previous write ... by goroutine 62:
... same path via TestExplainBundleIsShownOnlyToTheOwner() ai_secrets_test.go:58
scanner.New says "Call it once at start-up: the rules are parsed through viper's global instance" (internal/ai/redact/scanner/scanner.go:29-30). The gateway does call it once. The test helper secretsFixture (internal/gateway/apps/ai_secrets_test.go:20) calls it for every test, and those tests run with t.Parallel(), so two of them can parse gitleaks' rules at the same time. When the race detector fires, it fails whichever tests are running then, which is why the failing names vary.
Production is not affected. The fix is in the tests: build one scanner per package (for example with sync.OnceValues in the test file) and share it, since Scanner already guards its detector with a mutex. Making New itself safe to call concurrently would also work, but it would hide the "once at start-up" contract instead of keeping it.
- 主要言語
- Go
- スター
- 5
- フォーク
- 0
- 平均マージ
- 21時間 13分
- マージ済み PR(30日)
- 53
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nebari-dev/tapas のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
nebari-dev/tapas#124 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
nebari-dev/tapas#121 ·
メンテナーはふだん 1 日以内に返信
-
Suggest saving a memory when a chat message holds something worth remembering対応中かも @jbouder が今日担当しました。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
nebari-dev/tapas#137 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 54/100
nebari-dev/tapas#136 ·
メンテナーはふだん 1 日以内に返信
-
type: enhancement 💅🏼
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
nebari-dev/tapas#133 ·
メンテナーはふだん 1 日以内に返信
nebari-dev/tapas の issue をすべて見る
似ている issue
-
area: pipeline priority: low type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
prime-radiant-inc/evener#8335 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
ui: OnTextKey on SearchField never sees keys (it does not reach the inner input)対応中かも @szluyu99 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100