Repository navigation
[AI-3874] Fix flaky daytona refusal-size test - #2465
Conversation
The three oversize-answer tests bounded the bytes the fake server wrote, which includes what the host's socket buffers took before the router closed the connection. Count what the router read from the answer instead. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
kanat
left a comment
There was a problem hiding this comment.
VERDICT: GO
Reviewed 3bc019a merged onto main b36d78e. CI: draft, go and integration skipping; they run at gh pr ready.
Nit R1.1: the body says "The wait for the server's handler to end stays, with a deadline". The diff removes that Eventually from all three tests. Correct the sentence. The router closing the connection is still checked by TestARefusedDownloadHasEndedBeforeTheNextFileIsAskedFor, and no mutant tells the dropped wait from nothing (capped.Close returning nil survives on base too, because Run's deferred cancel closes the connection).
Nit R1.2: daytona_test.go:218-220 (unchanged lines): the upload refusal's counted wrapper and p.served["upload"] are now read by nobody, since the only sent("upload") reader was removed; the comment at line 54 still describes it. Dead after this PR; delete it or leave it.
Checked and sound:
- Root cause reproduced: Linux arm64 container, 3 processes x 50 runs x 3 tests, tcp_rmem/tcp_wmem max 32 MiB. Base 105 failures (
"45821248" is not less than "41943040"), head 0. Base with default buffers 0 (control). - Mutants: all the author's reproduce. Own mutants: cap lowered to 1 MiB fails on head (
"1048577" is not greater than "20971520") and passes on the base tests, so the new lower bound adds coverage.Closedraining the rest, slack past 2x and a half-counted cap fail on head and base alike; slack inside 2x andClosereturning nil survive on both. No mutant the base killed survives on head. - The upper bound keeps its meaning (the router read past the limit) and loses only the host-dependent part. No sleeps or new time dependence; the counter is atomic; whole package,
-race -count=20on the three tests, vet and gofmt are clean on the merged tree.
|
Round 1 nits, both fixed (head 07755ff):
|
kanat
left a comment
There was a problem hiding this comment.
VERDICT: GO
[reviewer delta R1] PR #2465, head 07755ff (previous reviewed head 3bc019a; merged onto origin/main 4a6dd11)
Prior findings
- R1.1 (Nit, PR body sentence about the removed wait): fixed. The body now says the wait is removed from the three tests. At 07755ff those tests contain no
Eventually(the old head already removed the three waits; main still has them atdaytona_test.go:844, 863, 881). - R1.2 (Nit, dead upload counter): fixed in 760d4e4.
grep -rn 'served\[\|"upload"' acceleration/internal/sandbox/daytona/shows no reader ofserved["upload"]; the upload refusal now writes throughio.Copy(w, ...)(daytona_test.go:218).countedis still used by the download path (daytona_test.go:305-309,:365).
Delta
- The PR's own diff of
daytona_test.goagainst main changed since 3bc019a only by the deletion: the upload-refusal counter lines (main's code, not this PR's) and the comment that described them. The merge of main has no conflict resolution (git show --remerge-diff 07755ff23is empty) and main has not touched the file since 15ce5c.
Checks (07755ff merged with origin/main 4a6dd11)
gofmt -lon the package: clean.go vet ./internal/sandbox/...: exit 0.go test -count=3 ./internal/sandbox/daytona/: ok.go test -race -count=10 -run 'TestDaytonaSuite/FarTooLarge': 30 of 30 PASS, no data race.- Mutants on the merged tree, the three FarTooLarge tests each time:
- T1, the counter sees no request: all three fail (
"0" is not greater than "20971520"). - T2, the counter counts nothing: all three fail.
- M1, upload answer not capped in
bounded.go:TestAnUploadsRefusalFarTooLargeIsNotReadWholefails ("209715200" is not less than "41943040"). - 3 checked, 0 survived. Each file was restored after its run.
- T1, the counter sees no request: all three fail (
New findings
None.
Not run
- CI: the PR is a draft, so
goandintegrationare skipped (#2130).Analyzeis pending and was not waited on. - Packages other than
sandbox/daytonawere not run; the delta does not touch them.
Why
TestDaytonaSuite/TestAnUploadsRefusalFarTooLargeIsNotReadWholefailed on CI with"44634104" is not less than "41943040"(run 45633422983, #2434). The ticket guessed process memory or GC. It is not: the test never measures the heap. It bounds the bytes the fake Daytona server wrote (counted,daytona_test.go:218-220), and that number is the bytes the router read plus whatever the kernel's socket buffers took before the router closed the connection. The buffer part is the host's setting (tcp_rmem/tcp_wmemmaxima), not the router's behaviour.The same flaw sits in the two sibling tests (
TestAFileFarTooLargeIsRefusedWithoutBeingReadWhole,TestADownloadsErrorFarTooLargeIsNotReadWhole), so all three are fixed here. No production change: the router reads at mostMaxFileBytes + downloadSlack + 1bytes (bounded.go:54,:65) in every run.Changes
tallied/tally: a transport under the router'sboundedwrapper that counts the bytes read from the bodies of one path. The three tests build their box throughtallyingBoxand assert on that count (requireReadUpToTheLimit): more thanMaxFileBytes(a counter that sees nothing fails) and less than2*MaxFileBytes(the old bound, same meaning).TestARefusedDownloadHasEndedBeforeTheNextFileIsAskedForstill checks that the router closes the refused connection.Validation
Base reproduction: macOS, 1.3k runs (
-count=50,-race, 16 parallel processes), no failure; Linux arm64 in Docker with the default buffers (tcp_rmemmax 6 MiB,tcp_wmemmax 4 MiB), 600 runs, no failure, server-side count up to 32.5M. With both maxima set to 32 MiB (docker run --sysctl), 3 processes x 50 runs x 3 tests:"44641350" is not less than "41943040")On the PR:
-count=50plain and-racegreen; 16 processes x 25-raceruns green; wholedaytonapackage green.Mutants (script and log in the author notes), each run against the three tests:
bounded.gocase)TestAnUploadsRefusal...fails, read 209715200TestADownloadsError...failsdownloadSlackraised to 1 GiBcapped.Readunclipped and never failsLimitReaderand cap both removed"0" is not greater than "20971520")Survivors, by design: unclipped
capped.Readalone (the error still comes after at most one buffer, under the 2x bound);capped.Closereturning nil (the request context's cancel closes the connection anyway,daytona.go:420-421); deleting either assertion line (the mutants above fail on exactly those lines).🤖 Generated with Claude Code