Repository navigation
fix(runners): a drain reaches the runner as GOAWAY, not a closed session (#278) - #833
Merged
Merged
Conversation
…ows it Signed-off-by: Alex <[email protected]>
Contributor
There was a problem hiding this comment.
Reviewed head 8fec8f1. The fix is in the right place: Accept is the only call that hides a GOAWAY behind a close, serve.go already treats ErrGoAway as the drain path, and §8.8 states the rule. The two tests cover the GOAWAY+1000 case and the close without GOAWAY. No review remarks requiring PR comments.
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.
Fixes #278: a drain could reach the runner as a closed session instead of GOAWAY.
Cause
The runner's
Sessionread the relay'sGOAWAYand then, with no stream open, the relay's1000 "drained"close. If both were read before the caller reachedAccept,Acceptsaws.errfirst and returnedErrSessionClosed, hiding the received GOAWAY. The relay sends GOAWAY first and closes only after the writer drained, so the server side is correct; the loss is in the client session's check order.Fix
runner/protocol/tunnel/session.go:AcceptreturnsErrGoAwaywhen GOAWAY was received and the session ended because the relay closed the connection with1000. Other endings (close without GOAWAY, other codes, heartbeat, localClose) keep their errors.runner/protocol/PROTOCOL.md§8.8: states the rule for GOAWAY followed by a close.Runner behaviour (item 3)
runner/internal/tunnel/manager.goalready treats GOAWAY and a relay close with 1000/1001 the same way (relayClosedNormally->outcomeGoAway): reconnect after up to 2 s of jitter, no backoff growth (§3.2). So a drained runner reconnected correctly in both cases; onlyAccept's error (and the flaky test) was wrong. A drain does not take the lost-connection path.Tests
TestRunnerAcceptReportsGoAwayWhenTheCloseFollowsIt(fails on develop with the exact CI message, passes after) andTestRunnerAcceptReportsAClosedSessionWhenTheCloseHasNoGoAway.go test -race -count=5000 -cpu 1,2,4 -run TestDrainSendsGoAwayAndStopsTakingConnections ./internal/relay/: 5085 failures in 15000 runs on develop, 0 in 15000 with the fix. (-count=300on develop did not reproduce.)go vetandgo test -race ./...pass inrunner/andrunner-relay/.