TestUploadStillUnderwayIsNotCutByHealthPing was red 3 of 3 on WSL
(magpie-desktop) at 7fe98c2af with "the vendor reading the body: client
disconnected", while the gateway got the vendor's right reply in 4.7s.
Cause: the #3909 fix lets the first try be cut by the lost ping, then
sends the body again. Both tries reach the vendor (counted on WSL and
mote: tries=2 each run). The cut try's handler stays blocked reading,
since the paced path never closes its vendor side, until the test's
cleanup closes the path. On Linux that read then fails, and the handler's
t.Errorf turned the test red. On macOS the abandoned try ends without an
error. The test asserted something the fix doesn't promise. The reply's
byte count still proves one try read the whole body.
What was run at this change on origin/main 7fe98c2af:
- gofmt -l internal/gateway: nothing; go vet ./internal/gateway/ (mote): ok.
- WSL: TestUploadStillUnderwayIsNotCutByHealthPing,
TestSlowUplinkSkipsTheLostTry, TestLargeBodyOnSilentConnectionIsSentAgain
-count=5: ok (70.6s). Before the change the first was red 3 of 3.
- mote: the same three, -race -count=3: ok. Windows (xiaomi-gpu): -count=3: ok.
- Broken by hand (the lostPing retry turned off), WSL: the test FAILs in
0.56s with "http2: client connection lost; want the vendor's reply".
Rebased onto e1721d640 (a GUI routing change only): the three tests
again on WSL -count=3 and mote -count=2: ok.
yxd-ym, on a 2-10KB/s uplink: every large turn to a Google upstream
(Antigravity, Vertex, AI Studio) failed with "http2: client connection
lost" after 35-45s while its body was still uploading, and the group's
failover uploaded the same ~680KB again to every member. A small turn on
the same uplink was answered in 14s.
Cause (skygunner's diagnosis): the vendor transport's HTTP/2 health check
(netproxy.HTTP2Health, #2843) pings a connection with no frame received
for 20s and drops it when no answer comes in 10s. The ping is written
behind the body's own DATA, so on a slow uplink its answer can only come
after the last byte, and the check closed a working connection.
skygunner's branch (8eaf63866) sent every body of 64KB or more, or of no
stated length, to a transport without the ping. That is most agent
traffic, and it takes #2843's protection away from it: a silent
connection whose kernel takes a body that fits the send buffer then
waits the 10-minute header wait (TestLargeBodyOnSilentConnectionIsSentAgain
below hangs to its 10s bound on that branch).
The change keeps the ping on every request by default. A large body
(uploading) whose try fails with Go's lost-ping error (lostPing,
closeForLostPing's "http2: client connection lost") is sent once more,
through GetBody (provider.SetBody keeps it until LetGo), through
uploadTransport: a new connection, no ping, given up on when a write
moves no bytes for a minute (WriteByteTimeout); the response header wait
still ends a vendor that never answers. For 30 minutes after (slowFor,
drawsApart.slow, per transport), large bodies go there at once, so a slow
uplink loses one try per half hour, not one per turn. A connection that
really was dead costs nothing more: the retry dials a new one either way.
Small bodies and drawings are unchanged.
Co-authored-by: vincent <vincent@users.noreply.github.com>
Reported-by: yxd-ym
What was run, on mote at origin/main ea53eb126 + this:
- gofmt -l internal/gateway: nothing. go vet ./internal/gateway/
./internal/netproxy/, and GOOS=linux / GOOS=windows go vet
./internal/gateway/: nothing.
- TestUploadStillUnderwayIsNotCutByHealthPing (skygunner's: 262212 bytes
paced at 64KB/s, ping after 200ms, dropped 300ms later),
TestSlowUplinkSkipsTheLostTry (new: the first large body reaches the
vendor twice, the second once, body given through provider.SetBody),
TestLargeBodyOnSilentConnectionIsSentAgain (new: 128KB body after the
path went silent is answered on a second connection),
TestSilentHTTP2ConnectionIsDropped, TestGroupMovesOnFromSilentHTTP2Connection:
-race -count=5 all PASS (80s); -count=3 without -race PASS.
- Broken by hand:
- skygunner's transport alone: TestSlowUplinkSkipsTheLostTry FAIL ("saw
1 tries of the first body, want 2"), TestLargeBodyOnSilentConnection
IsSentAgain FAIL (context deadline exceeded at 10.01s).
- the retry removed: TestUploadStillUnderwayIsNotCutByHealthPing FAIL
in 0.57s ("http2: client connection lost", vendor "client
disconnected"), TestLargeBodyOnSilentConnectionIsSentAgain FAIL
(client connection lost).
- go test ./internal/gateway/ ./internal/netproxy/ ./internal/provider/
-count=1 -timeout 45m: ok
(gateway 546s, netproxy 3.7s, provider 118s).
Rebased onto f02d92c7b (no change to these files but a doc line
elsewhere in gateway-routing.md): gofmt, go vet (darwin, linux,
windows) ./internal/gateway/, and the five tests above with
TestPromptText* and *Unmasked* -count=2: ok (32s).
Not tried: the reporter's uplink and a real Google upstream; the path is
a paced local one.