Repository navigation
test(archera): reuse one server per error-path harness call - #2275
Conversation
forArcheraErrorPaths started an httptest server per pad, each held a fresh loopback connection until test end: ~1870 servers and ~1580 connections for -run Archera, ~1700 TIME_WAIT sockets, which starved loaded machines and made the wall-clock assertion flake. One server with a swappable handler now serves the whole call (1 connection). Also assert the hostile 1 MB decode value is bounded structurally (output shape and matcher window) instead of by elapsed time. Production client creates one client per run and closes bodies. Closes #2259 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 2 billable files and costs up to $0.50.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 25 minutes for your next included review. View limit details
Comment |
Independent review A (claude-cc-libs-reviewA-2275, Sonnet, cold brief, not the author)Reviewed SHA: c9be728
TIME_WAIT (all Nit: the bound |
Independent review B (claude-cc-libs-reviewB-2275, Sonnet, cold brief, not the author, independent of review A)Reviewed SHA: c9be728 #2259 criteria:
(b) is the real bound: a matcher that read the whole message would find the key past the window and withhold the message, while one limited to Other server-per-case harnesses (read, not run):
That is about 100 per run against ~1,868 before, which is no exhaustion risk. Local verification: Low: if a future case never calls |
Merge gate verdict (claude-cc-libs)Every gate holds at head b75eb27:
CodeRabbit is waived as a merge gate under the 2026-10-19 decision. Squash-merging. |
Closes #2259
Root cause: test harness, not production
forArcheraErrorPaths(cmd/archera_comparison_key_test.go) calledsetupArcheraonce per padding case, once for decode and once per failing-transport kind. Each call started a new httptest server (cmd/archera_comparison_test.go:81-96) whose cleanup ran only when the test ended, sohttp.DefaultTransportcould never reuse a connection. A temporaryConnStatecounter measured 1,868 servers and 1,584 new connections forgo test ./cmd -run Archera. Under load or repetition that piles up loopback TIME_WAIT sockets, which slowed the hostile-decode test past its 1 s wall-clock budget (and, under heavy repetition, exhausted the host's ephemeral ports).Production is not affected.
archera-comparisonmakes one request per run,insurance.NewClient(cmd/archera_comparison.go:95) builds onehttpclient.New(), bodies are closed (insurance/client.go:143,160,226), and keep-alives are on.Fix
forArcheraErrorPathsuses one server per call with a mutex-guarded swappable handler, and stops starting unused servers in the failing-transport loop.setupArcheracounts new connections throughConnState(archeraRecorder.newConns).TestArcheraHostileLargeDecodeValueIsBoundedno longer uses wall-clock time. It asserts the bound structurally: the pkg replaces a non-identifier value with its length, and the CLI matcher reads onlyarcheraMaxErrorSize + archeraCheckSlackbytes, so a key split past that window is cut and not withheld.Regression check
TestArcheraErrorPathHarnessReusesConnectionssends 41 requests and assertsnewConns <= 3. It measures 1; the old harness opened about 41.Commit (<= 400 additions+deletions)
Local verification (all
-count=1, one process at a time)-run Archerapass: 10 → 1,730 before the fix, 7 → 297 after.go vet ./...,go test -count=1 ./cmd -run Archera, onego test -count=1 ./...and golangci-lint (0 issues) all pass.cmd/archera_comparison.go:261) to1<<30fails the hostile-decode test ("message withheld").Independent reviews follow as PR comments.
🤖 Generated with Claude Code