Commit 34366cf
fix: prevent replication neighbor sync from blocking shutdown under active traffic
The neighbor sync loop ran `run_neighbor_sync_round()` outside of its
`tokio::select!` block. When shutdown was cancelled mid-round, the task
couldn't notice until the entire sync round completed — which involves
multiple network round-trips to peers that may themselves be shutting
down, causing extended blocking.
Wrap the sync round in a `tokio::select!` with `shutdown.cancelled()` so
in-progress operations are cancelled immediately when shutdown fires.
Also add a 10-second timeout to the replication engine's task joins in
`shutdown()` as defense in depth, matching the same pattern applied to
`DhtNetworkManager::stop()`.
Discovered during auto-upgrade testing on a 151-node testnet with active
client uploads. The DHT shutdown fix (saorsa-core) resolved 98% of
hangs; this fix resolved the remaining 2%.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 27aa635 commit 34366cf
1 file changed
Lines changed: 27 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | | - | |
259 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
260 | 268 | | |
261 | 269 | | |
262 | 270 | | |
| |||
435 | 443 | | |
436 | 444 | | |
437 | 445 | | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
450 | 463 | | |
451 | 464 | | |
452 | 465 | | |
| |||
0 commit comments