Commit a43767d
authored
fix: close head tracker/broadcaster before balance monitor to prevent race (#425)
Reorder chain.Close() to stop event sources (headTracker,
headBroadcaster) before event consumers (balanceMonitor). Previously,
the balance monitor was closed while the head pipeline was still
running, allowing headBroadcaster to deliver a last-second
OnNewLongestChain that wakes the balance monitor's SleeperTask.
When SleeperTask.Stop() then closes chStop, both chStop and chQueue
are ready in the select — Go picks randomly, and 50% of the time
runs one more Work() that calls BalanceAt on a torn-down mock client,
triggering a data race detected by go_core_race_tests.1 parent dbcbab4 commit a43767d
1 file changed
Lines changed: 10 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
380 | 384 | | |
381 | 385 | | |
382 | 386 | | |
383 | 387 | | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
394 | 400 | | |
395 | 401 | | |
396 | 402 | | |
| |||
0 commit comments