Panic: Unwrapping send on closed report channel causes ReceiveClosed in worker tasks under load
評価
調査の方向性
src/client.rs の 1245–1250 行付近から始め、早期シャットダウン中の report channel の receiver のライフタイムを追跡します。issue で言及されている send(...).unwrap() 呼び出しが他の worker/reporting パスにもないか監査します。提供された高並行性の再現ケースでも、閉じられた receiver が worker の panic を引き起こさなくなれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
When running oha with high concurrency (e.g. -n 5000 -c 1000) and especially with --latency-correction enabled, worker tasks can panic with:
panic at src/client.rs:1254:49: called `Result::unwrap()` on an `Err` value: ReceiveClosed
Reproduction
Run:
oha 'http://localhost:9000/api/requests/' -n 5000 -c 1000 -m POST --latency-correction -H 'Content-Type: application/json' -d '{"email":"[email protected]"}'
The panic is much more likely at high concurrency or when early shutdown occurs. It is triggered when the result receiver closes before all worker tasks finish.
Root cause
Code at src/client.rs:1245-1250:
while counter.fetch_add(1, Ordering::Relaxed) < n_tasks {
let res = client.work_http1(&mut client_state).await;
let is_cancel = is_cancel_error(&res);
report_tx.send(res).unwrap();
if is_cancel { break; }
}
When the receiver is closed (for example, when test duration or parent task completes), further sends panic workers via .unwrap().
Impact
This is a race between result reporting and the receiver's lifetime. In normal or high-pressure use, fast termination of the receiver (parent) leaves workers panicking on .unwrap() if they race to send results after closed.
Possible solutions
- Change all
report_tx.send(...).unwrap();sites to handle channel closure gracefully, e.g.:if report_tx.send(res).is_err() { break; } - Prefer
ok()and silent exit when the receiver is gone, since there's nothing further the worker can do. - Audit all other worker/reporting codepaths for
send(...).unwrap()(other than in tests) and apply similar fix.
Let me know if you need details or logs would be useful.
- 主要言語
- Rust
- スター
- 10.7k
- フォーク
- 311
- 平均マージ
- 24分
- マージ済み PR(30日)
- 6
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
hatoo/oha のほかの issue
-
難易度 2/5 半日 初心者へのやさしさ 62/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 28/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
HTTP/3 very slowオープン
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
似ている issue
-
marketing
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
help wanted small extra
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
anomalyco/rune#2432 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
n0-computer/net-tools#282 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
eliasstravik/herdr-projects#1551 ·