evict an outgoing peer that closed before the cache published it - #777
Merged
Conversation
The outgoing watcher starts inside the ocache load func, before the value is published, and RemoveSame deliberately never matches a still-loading entry (a nil value would wait the load out and close whatever it publishes). A connection dying in that window left the closed peer published with no watcher left to evict it, so it lingered until the next Get self-healed it or the TTL reaped it, and the observer reported Closed for a peer the pool had not accepted. Wait the load out before removing. Incoming peers are published synchronously by AddPeer, so that path keeps removing without a wait.
Coverage provided by https://github.com/seriousben/go-patch-cover-action |
requilence
self-requested a review
September 1, 2026 17:00
requilence
approved these changes
Sep 1, 2026
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.
Not a regression from this release train — the structure dates to
08f8d6d3(PR #693,go-7301-quic-pool-eviction, 2026-06-01) and has shipped since v0.12.6. #773 made one consequence newly visible by adding theKindClosednotification toevictOnClose.The outgoing watcher is started from inside the ocache load func, before the value is published.
RemoveSamedeliberately never matches a still-loading entry — its comment is explicit that matching a nil value would wait the load out and close whatever the load publishes. So a connection dying in that window meant:RemoveSamereturnedErrNotExistsand the watcher exited, leaving the closed peer to be published with no watcher at all — it lingered until the nextGetself-healed it or the TTL reaped it;KindClosedfor a peer the pool had not yet accepted (no precedingKindConnected).Waiting the load out via
Pickbefore removing fixes both, and keeps the existing "never close a live replacement" invariant:RemoveSamestill only removes this exact peer, so if another value took the id nothing happens. Incoming peers are published synchronously byAddPeer, so that path removes without a wait and is untouched.TestPool_EvictsOutgoingClosedDuringLoaddrives the seam directly — a load held open while the peer closes — and fails without the fix (closed peer must not stay cached after the load publishes).go test -race ./net/pool/...green.🤖 Generated with Claude Code
https://claude.ai/code/session_01HXNxMzxa6rK3bAwcULTt4x