GO-7556: recover from stale connections after sleep/wake - #801
Closed
requilence wants to merge 3 commits into
Closed
requilence wants to merge 3 commits into
requilence wants to merge 3 commits into
Conversation
net/pool: - Flush bumps a pool generation; peers are stamped at dial start / AddPeer and every lookup rejects older-generation peers, so a peer restored by ocache GC or published by a dial that spanned the flush can never be handed out again (no ocache changes). - Instance-safe cleanup (RemoveSame) everywhere; stale peers are closed asynchronously, including ones not visible to ForEach. net/peer: - Per-peer lazy cleanup owner: synchronous sub-conn closes (ReleaseDrpcConn, failed handshake, peer gc) move off the caller path; in-flight closes count toward the open limiter; the MultiConn is closed only on stall evidence (threshold derived from the transport write timeout). - Conns handed to the owner by gc are never reused. net/transport: - yamux Open honours ctx (bounded abandoned helpers). - QUIC stream Read/Write wrap connection-death errors as ErrConnClosed. - Optional WriteTimeouter for yamux/quic/iroh/webtransport. net/secureservice/handshake: - OutgoingProtoHandshakeWithCloser: cancellation hands the conn to a closer exactly once; legacy OutgoingProtoHandshake keeps its contract.
Coverage provided by https://github.com/seriousben/go-patch-cover-action |
…Write On the yamux (TCP fallback) transport a session shutdown made stream Read return io.EOF / stream reset, which drpc v1.0.0 turns into a bare context.Canceled, so callers couldn't tell connection loss from their own cancellation. Mirror the QUIC normalization: ErrSessionShutdown, and EOF/reset/stream-closed while the session is closed, wrap transport.ErrConnClosed (original error still reachable via errors.As). A normal remote stream close stays a plain io.EOF.
Callers can now classify TLS handshake I/O failures (EOF, reset, timeout) with errors.Is/As. Type assertions and sentinel comparisons are unaffected.
3 of 4 tasks
Contributor
Author
|
Superseded by #802: same scope, but pool.Flush is now a cache swap instead of per-peer generation stamps. It's simpler, closes a case where a Get after Flush could wait out a pre-flush dial, and cached lookups are faster than main. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
After sleep/wake, clients keep reusing dead pre-sleep connections. Handshakes and RPCs hang for 10–30s+, and
pool.Flushcan miss peers that ocache GC is closing or that a dial publishes after the flush.Changes
Flushbumps a pool generation. Peers are stamped at dial/AddPeer, and every lookup rejects older-generation peers, so a peer restored by GC or published late is never handed out. Cleanup usesRemoveSameeverywhere, and stale peers are closed asynchronously. No ocache changes.Openhonours ctx.ErrConnClosed.OutgoingProtoHandshakeWithCloser. The legacy function keeps its contract.transport.WriteTimeouter,handshake.OutgoingProtoHandshakeWithCloser.Test plan
go test -race ./net/... ./app/ocache/...; new tests at-count=20..200Linear: GO-7556