Commit 8f23985
committed
fix(puller): non-blocking peer disconnect and sync error backoff
When onChange held syncPeersMtx and called disconnectPeer, the inner
peer.stop() cancelled per-bin goroutine contexts and then called
peer.wg.Wait(). Live goroutines blocked in Sync() → ReadMsgWithContext
and only unblocked after pageTimeout (1s) per stream. For N peers
disconnecting during a radius decrease, the outer lock was held for up
to N×1s, stalling all queued topology-change notifications for the same
duration.
When syncer.Sync returned a non-fatal error (connection reset, protocol
error, stream timeout), the goroutine fell through to limiter.WaitN with
count=0 and looped immediately. Any persistent non-fatal error caused a
tight CPU spin until the peer disconnected or context was cancelled.
Split syncPeer.stop() into cancelBins() (cancel all per-bin contexts,
clear the map, no wait) and stop() (cancel + wait, used only in
Close()). disconnectPeer now calls cancelBins(): the peer is removed
from the sync map immediately and its goroutines drain in the
background. Close() already calls p.wg.Wait(), so shutdown correctness
is unchanged.
Add syncRetryBackoff (1s) with a ctx.Done()-escape after any non-fatal
sync error before the next retry. This bounds the retry rate to ≤1/s
per goroutine under persistent errors.1 parent 61fab37 commit 8f23985
2 files changed
Lines changed: 71 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
189 | 191 | | |
190 | 192 | | |
191 | 193 | | |
| 194 | + | |
192 | 195 | | |
193 | 196 | | |
194 | 197 | | |
195 | 198 | | |
196 | 199 | | |
197 | | - | |
| 200 | + | |
198 | 201 | | |
199 | 202 | | |
200 | 203 | | |
| |||
349 | 352 | | |
350 | 353 | | |
351 | 354 | | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
352 | 360 | | |
353 | 361 | | |
354 | 362 | | |
| |||
548 | 556 | | |
549 | 557 | | |
550 | 558 | | |
551 | | - | |
552 | | - | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
553 | 562 | | |
554 | 563 | | |
555 | 564 | | |
556 | 565 | | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
557 | 572 | | |
558 | 573 | | |
559 | 574 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
510 | 563 | | |
511 | 564 | | |
512 | 565 | | |
| |||
0 commit comments