Repository navigation
fix(core): stop dialling a session the tunnel service abandoned - #182
Merged
Merged
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
One session id must carry one local session and one tunnel. WatcherRegister now claims the id in a bounded SessionDialGuard before it opens the LocalSession, so a repeat delivery of the same id (the edge re-proposes it after proposalAnswerTimeout, a watch fail-over re-publishes it) is absorbed instead of dialled a second time, and the dial already in flight still decides the session. Also classify the tunnel service's "session <id> not found ... pendingState= released" answer (and 410) as an abandonment instead of a transport error: WebSocketTunnelTransport reports it through TunnelConn.Handler.onSessionAbandoned, LocalChannelInboundHandler latches the id, rejects the proposal with UNAVAILABLE instead of UNKNOWN "local connection closed" and tears the local session down, and Tunneler throws SessionAbandonedException instead of dialling a latched id. RED before the fix (core:...register.TunnelDialAfterAbandonTest): two dials for one session id, a dial for an abandoned session, and rejection code 2 UNKNOWN instead of 14 UNAVAILABLE. GREEN after, with SessionDialGuardTest pinning the bounded retention/eviction of the latch.
…iled claims Dedupe repeat deliveries in WatchClient before the admission coordinator stages a new admission, so a dropped repeat can no longer supersede the first delivery's admission. Release the in-flight claim when the delivery is rejected, latch abandonment only on 410 or a 404 reporting a released pending entry, and keep the guard's pruning O(expired).
robinbraemer
force-pushed
the
fix/tunnel-abandoned-session-dial
branch
from
November 24, 2026 22:24
e2ce961 to
345c388
Compare
…sed' 404, not its static causes text The edge's 404 body always ends with 'likely causes: expired session, released session (...)', so matching 'not found' plus 'released' latched every tunnel-service 404, including wrong-instance and expired ones. Match the authoritative 'pending metadata released' field of moxy's missing-session response and use that exact body in the fixtures.
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.
Root cause
A connector can issue more than one tunnel dial for one session id: an edge re-proposal after
its answer window expires, or a watch fail-over re-publish. When such a dial lands after the edge
has already given up on the session — the tunnel service answers
404 session <id> not found … pendingState=released— the pre-fix connectorUNKNOWN "local connection closed")instead of
UNAVAILABLE, andChange
SessionDialGuard(new, bound@Singleton): a bounded per-session-id registry.tryAcceptDeliveryclaims an id once,
abandonlatches “the tunnel service no longer knows this session”. Retention 30 s(the edge's 2 × 3 s answer budget + the connector's 10 s connect timeout + the dial), max 8192 entries,
oldest-first eviction. No clock-based heuristic.
WatcherRegister.onProposalclaims the id before opening aLocalSession. A latched id isrejected with
UNAVAILABLEand never dialled; a repeat delivery of an id that is already dialling isdropped, not rejected — a rejection would answer for the delivery that is still dialling.
Tunneler.tunnel(…)throwsSessionAbandonedExceptioninstead of dialling a latched id, so theinvariant is enforced at the dial site, not only at intake.
WebSocketTunnelTransportmaps the tunnel service's404(pendingState=released) and410to thenew
TunnelConn.Handler.onSessionAbandoned— noonError, no retry. The Netty local channel thenrejects and closes instead of dialling, and the player-facing rejection is
UNAVAILABLE.CommonModulebinds the guard so register and tunneler see the same latch.Scope and limits
needs an edge-side bounded “session abandoned” notice (or
410+X-Connect-Session-State), trackedseparately. The first dial of a released entry is still issued, so this change alone does not eliminate
the
released+pendingAge > 3 sedge log class.Tunnelerper offer and keeps no cross-offer abandonment memory.Production runs the WebSocket path; flagged, not changed.
isSessionAbandonedkeys on any404/410without parsing the body, so the tunnel service's other404 causes (expired entry, duplicate tunnel, wrong instance) also latch the id for 30 s. All of those
already ended the session pre-fix, so no working path is lost.
window is dropped silently (intended: one session id, one local session, one tunnel).
Verification
:core:testTunnelDialAfterAbandonTest5f2eb27with only the test file: 3/3 failed (0 vs 1 dial, 1 vs 2 dials, code 2UNKNOWNvs 14UNAVAILABLE) → GREEN 3/3 at this headSessionDialGuardTest./gradlew buildcheckincludedSessionProposal.rejectis a one-shot CAS, soUNAVAILABLEcannot be overwritten by the later close reject and no live tunnel can be rejectedThe two new test classes run inside
./gradlew build, so the JDK 17 + 21 matrix exercises them.Follow-ups (not in this diff)
released entry.
AGENTS.mdinvariant section — docs-only, proposed for a maintainer to apply:## Tunnel dials are per session id(paste-ready)Do not call production fixed from this release alone: the released jar has to be in the hub image, the hub
pod has to log the plugin version, and the edge has to accept a tunnel with that same
connectorVersion.