Panic: Unwrapping send on closed report channel causes ReceiveClosed in worker tasks under load
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
Direzione di ricerca
Inizia in src/client.rs intorno alle righe 1245–1250 e traccia la durata di vita del ricevitore del canale dei report durante l’arresto anticipato. Verifica gli altri percorsi di worker/reporting alla ricerca delle chiamate a send(...).unwrap() menzionate nell’issue. Il lavoro è completato quando i ricevitori chiusi non causano più panic dei worker, anche con la riproduzione fornita ad alta concorrenza.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Rust
- Stelle
- 10.7k
- Fork
- 311
- Merge medio
- 24m
- PR unite (30g)
- 6
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di hatoo/oha
-
Difficoltà 2/5 Mezza giornata Idoneità per principianti 62/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 28/100
-
TTFB info in regular outputAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
HTTP/3 very slowAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
Issue simili
-
marketing
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
help wanted small extra
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
anomalyco/rune#2432 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
netwatch: support tvOSAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
n0-computer/net-tools#282 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
eliasstravik/herdr-projects#1551 ·