Files
magpie/internal
yetone 29181eb78e gateway: the 64MB body tests get room before routing under -race only (#3957)
TestLargeRequestEndpoints and TestRequestTailAfterOldLimit went red on
main's Race jobs (macOS at ec6c2de52 and 56602426d, ubuntu at
874b86653): the Codex backend subtest's oldBodyLimit body was answered
magpie's own 504, "held this request for 30s without routing it".

Profiled on mote (M5 Pro): the subtest takes 0.89s without -race and
22.4s with it. 62% of the CPU is the race runtime itself and the rest is
the body's scans before routing (skipJSONSpace, decodeJSONIn, trimJSON,
bodyEffort, metadataOf), each instrumented per read. CI runners are
slower and share the shard, so 50 to 58s. A user's machine sees the
0.89s, far inside the 30s cut, so the cut is right and the test's
clock under -race is what's wrong.

largeBodyRoom lifts unroutedUnknown and unroutedMost to 10 minutes when
raceOn, for the three tests that serve such a body through the handler
(TestLargeRequestEndpoints, TestRequestTailAfterOldLimit,
TestCodexCompressedTailError). Without -race the 30s cut stays, so a
scan made 30x slower still fails them.

Run at this tree (origin/main 0dc4cec85..):
- Reproduced: with no room and a 10s cut under -race, the Codex subtest
  gives CI's message word for word ("held this request for 10s").
- With the room, -race: the three tests and TestUnrouted* ok (179s).
  Without -race: those three and TestCodexBodyReadsPastOldLimit ok (10s).
- go vet ./internal/gateway, with -tags race, GOOS=linux, GOOS=windows ok;
  gofmt -l clean.
Not run: the full ./... suite; the shard's 20m budget on CI (the next
Race run shows it).
2026-10-28 21:19:08 +08:00
..
…
…
…