Repository navigation
device: retry receive funcs on every read error but net.ErrClosed - #116
Merged
Merged
Conversation
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
creachadair
approved these changes
Oct 30, 2026
Co-authored-by: M. J. Fromberger <[email protected]>
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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