Skip to content

device: retry receive funcs on every read error but net.ErrClosed - #116

Merged
illotum merged 2 commits into
tailscalefrom
illotum/spin-read-errrors
Oct 30, 2026
Merged

illotum merged 2 commits into
tailscalefrom
illotum/spin-read-errrors

Conversation

@illotum

@illotum illotum commented Oct 30, 2026

Copy link
Copy Markdown

RoutineReceiveIncoming bailed on anything net.Error.Temporary()
did not cover, leaving the receive path dead for the life of the
process.

Retry everything but net.ErrClosed, move pacing to be the Bind
responsibility. For simplicity the in-repo Binds do not pace.

Updates: tailscale/tailscale#22097

RoutineReceiveIncoming bailed on anything net.Error.Temporary()
did not cover, leaving the receive path dead for the life of the
process.

Retry everything but net.ErrClosed, move pacing to be the Bind
responsibility. For simplicity the in-repo Binds do not pace.

Updates: tailscale/tailscale#22097

Signed-off-by: Alex Valiushko <[email protected]>
Change-Id: I2542c58babb6877ec35ee63d7ee531ed6a6a6964
Comment thread conn/conn.go Resolved
Co-authored-by: M. J. Fromberger <[email protected]>
@illotum
illotum merged commit 348934c into tailscale Oct 30, 2026
15 checks passed
@illotum
illotum deleted the illotum/spin-read-errrors branch October 30, 2026 21:00
nbeirne added a commit to tailscale/tailscale that referenced this pull request Nov 5, 2026
This iterates on the work in #21902, #22100 and tailscale/wireguard-go#116.

The new version of wireguard-go discards the deathSpiral loop in favour
of allowing Bind's ReceiveFunc to pace read retries. This code is the
other side. Add back a backoff for non-feedback errors, and report the
receive func as broken to the health tracker once reads have been
failing for 30s. The loop only exits once net.ErrClosed is returned.

Updates #22097

Change-Id: I9f1134242c3cb5ac2ef3c282cf7bcd7606cb5b9e
Signed-off-by: Nick Beirne <[email protected]>

.

Change-Id: Iccfb5e3746d212856978e9f539f848fccf85058a

.
nbeirne added a commit to tailscale/tailscale that referenced this pull request Nov 5, 2026
This iterates on the work in #21902, #22100 and tailscale/wireguard-go#116.

The new version of wireguard-go discards the deathSpiral loop in favour
of allowing Bind's ReceiveFunc to pace read retries. This code is the
other side. Add back a backoff for non-feedback errors, and report the
receive func as broken to the health tracker once reads have been
failing for 30s. The loop only exits once net.ErrClosed is returned.

Updates #22097

Change-Id: I9f1134242c3cb5ac2ef3c282cf7bcd7606cb5b9e
Signed-off-by: Nick Beirne <[email protected]>

.

Change-Id: Iccfb5e3746d212856978e9f539f848fccf85058a

.
nbeirne added a commit to tailscale/tailscale that referenced this pull request Nov 5, 2026
This iterates on the work in #21902, #22100 and tailscale/wireguard-go#116.

The new version of wireguard-go discards the deathSpiral loop in favour
of allowing Bind's ReceiveFunc to pace read retries. This code is the
other side. Add back a backoff for non-feedback errors, and report the
receive func as broken to the health tracker once reads have been
failing for 30s. The loop only exits once net.ErrClosed is returned.

Updates #22097

Change-Id: I9f1134242c3cb5ac2ef3c282cf7bcd7606cb5b9e
Signed-off-by: Nick Beirne <[email protected]>
nbeirne added a commit to tailscale/tailscale that referenced this pull request Nov 6, 2026
This iterates on the work in #21902, #22100 and tailscale/wireguard-go#116.

The new version of wireguard-go discards the deathSpiral loop in favour
of allowing Bind's ReceiveFunc to pace read retries. This code is the
other side. Add back a backoff for non-feedback errors, and report the
receive func as broken to the health tracker once reads have been
failing for 30s. The loop only exits once net.ErrClosed is returned.

Updates #22097

Change-Id: I9f1134242c3cb5ac2ef3c282cf7bcd7606cb5b9e
Signed-off-by: Nick Beirne <[email protected]>
nbeirne added a commit to tailscale/tailscale that referenced this pull request Nov 6, 2026
This iterates on the work in #21902, #22100 and tailscale/wireguard-go#116.

wireguard-go no longer has a deathSpiral loop; it relies on the Bind's
ReceiveFunc to pace read retries. This is the magicsock side of that
change.

On read errors other than truncation and UDP read feedback, the receive
func now sleeps 100ms and retries rather than returning. If reads keep
failing for 30s it marks itself broken via ReceiveFuncStats.SetBroken.
The next successful read clears that state.

Updates #22097

Change-Id: I9f1134242c3cb5ac2ef3c282cf7bcd7606cb5b9e
Signed-off-by: Nick Beirne <[email protected]>
nbeirne added a commit to tailscale/tailscale that referenced this pull request Nov 10, 2026
tailscale/wireguard-go#116 changed the receive loop to retry any errors
other than net.ErrClosed without a delay. magicsock entered a spin loop
if it encountered a UDP read error.

magicsock's receive funcs now return only net.ErrClosed when the socket
actually closes. A IsUDPReadFeedback error is retried without delay and
other errors are retried after readErrRetryDelay.

Retrying errors may hide failures which used to stop the receive func.
- A repeated error is now logged at most once every 5s.
- There is a new metric magicsock_recv_udp_error which counts all read
  errors.
- After 30s of continuous errors, the receive function marks itself as
  broken. A warning is raised until a read succeeds.

Updates #22097

Change-Id: Ib9ade0ed001e413205eb7d452aa108aae574e0d1
nbeirne added a commit to tailscale/tailscale that referenced this pull request Nov 10, 2026
tailscale/wireguard-go#116 changed the receive loop to retry any errors
other than net.ErrClosed without a delay. magicsock entered a spin loop
if it encountered a UDP read error.

magicsock's receive funcs now return only net.ErrClosed when the socket
actually closes. A IsUDPReadFeedback error is retried without delay and
other errors are retried after readErrRetryDelay.

Retrying errors may hide failures which used to stop the receive func.
- A repeated error is now logged at most once every 5s.
- There is a new metric magicsock_recv_udp_error which counts all read
  errors.
- After 30s of continuous errors, the receive function marks itself as
  broken. A warning is raised until a read succeeds.

Updates #22097

Change-Id: Ib9ade0ed001e413205eb7d452aa108aae574e0d1
nbeirne added a commit to tailscale/tailscale that referenced this pull request Nov 10, 2026
tailscale/wireguard-go#116 changed the receive loop to retry any errors
other than net.ErrClosed without a delay. magicsock entered a spin loop
if it encountered a UDP read error.

magicsock's receive funcs now return only net.ErrClosed when the socket
actually closes. A IsUDPReadFeedback error is retried without delay and
other errors are retried after readErrRetryDelay.

Retrying errors may hide failures which used to stop the receive func.
- A repeated error is now logged at most once every 5s.
- There is a new metric magicsock_recv_udp_error which counts all read
  errors.
- After 30s of continuous errors, the receive function marks itself as
  broken. A warning is raised until a read succeeds.

Updates #22097

Change-Id: Ib9ade0ed001e413205eb7d452aa108aae574e0d1
Signed-off-by: Nick Beirne <[email protected]>
nbeirne added a commit to tailscale/tailscale that referenced this pull request Nov 12, 2026
tailscale/wireguard-go#116 changed the receive loop to retry any errors
other than net.ErrClosed without a delay. magicsock entered a spin loop
if it encountered a UDP read error.

magicsock's receive funcs now return only net.ErrClosed when the socket
actually closes. Every other read error is counted, logged, and retried
after a short delay. IsUDPReadFeedback and IsUDPReadUnknown are removed
because they can be handled like any other error.

Retrying errors may hide failures which used to stop the receive func.
- There is a new metric magicsock_recv_udp_error which counts all read
  errors.
- After 30s of continuous errors, the receive function marks itself as
  broken. A warning is raised until a read succeeds.

Updates #22097

Change-Id: Ib9ade0ed001e413205eb7d452aa108aae574e0d1
Signed-off-by: Nick Beirne <[email protected]>
nbeirne added a commit to tailscale/tailscale that referenced this pull request Nov 12, 2026
tailscale/wireguard-go#116 changed the receive loop to retry any errors
other than net.ErrClosed without a delay. magicsock entered a spin loop
if it encountered a UDP read error.

magicsock's receive funcs now return only net.ErrClosed when the socket
actually closes. Every other read error is counted, logged, and retried
after a short delay. IsUDPReadFeedback and IsUDPReadUnknown are removed
because they can be handled like any other error.

Retrying errors may hide failures which used to stop the receive func.
- There is a new metric magicsock_recv_udp_error which counts all read
  errors.
- After 30s of continuous errors, the receive function marks itself as
  broken. A warning is raised until a read succeeds.

Updates #22097

Change-Id: Ib9ade0ed001e413205eb7d452aa108aae574e0d1
Signed-off-by: Nick Beirne <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants