fix(udp): treat only n < len(b) as a short write (#1029)#37
Merged
Conversation
A proxy WriteTo may report the on-wire byte count including protocol encapsulation overhead (shadowsocks AES-128-GCM + IPv4 = +39 bytes), so n can legitimately exceed len(b). UDP datagrams are atomic; only n < len(b) is a genuine short write. The old n != len(b) misread every over-count as a short write, retiring healthy endpoints and exhausting the retry limit. Evidence: 10655/10655 captured drops were exactly +39 over-writes with retry exhausted and zero genuine under-writes.
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.
What
Minimal correctness fix for the UDP data-path retry storm:
UdpEndpoint.WriteTonow treats onlyn < len(b)as a short write, instead ofn != len(b).A proxy
WriteToreports the on-wire byte count, which includes the outbound protocol's encapsulation overhead (shadowsocks AES-128-GCM + IPv4 = +39 bytes), soncan legitimately exceedlen(b)on a fully successful write. UDP datagrams are atomic; onlyn < len(b)is a genuine short write. The old check retired healthy endpoints and exhausted the retry limit, surfacing asTouch max retry limit.warnings.Evidence
WriteToerrors showed 10655/10655 retry-exhaustion drops were exactlyn = len(b)+39over-writes (delivered on the wire), zero genuine under-writes.Touch max retry limit.events.Scope
dae/mainand cherry-picked clean (2 files, gofmt-clean).+39over-write stays alive; genuine partial write still retires +io.ErrShortWrite.fix/healthcheck-retry-evidence-1026-1029, intentionally excluded here.Replaces #36 (closed).