carlos / platform Public

Flake: TestDBForwardLongRequestThroughTheEdge (restore takes ~20 s under shard load) Issue closed

Failed twice on 2026-11-14 on branches that don't touch the code under test: remove-tito-console-alias-refs (comments/docs only) and pdf-host-client-groups (infra/modules/pdf-host only), shard root@2, about 21-22 s each. The log shows dbreads: ... planned 2 files (973 bytes) and restored to 2 in 20.01s: a two-file restore taking 20 s suggests the test's restore path waits on a timer or backoff under CI load and then trips its own deadline. Both reran green.

Investigation so far (systematic, no fix yet because the root cause isn't known):

  • Both CI failures took ~21.6 s in total against ~47 s for a pass, so the first raw read (20 s by design, slowRestore) succeeded and the CLI read failed about a second after starting, inside checkProgressAtTheCLI. The log has no console: db read ... relayed ... ended done line before the trace dump, which every passing run has.
  • Ruled out: the console's read admission (OpenPerPerson = 2, so one read still closing doesn't refuse the next) and edges liveness (the fake box's status is minutes fresh).
  • Could not reproduce: 4 local runs and 3 pinned to one contended core all pass (46-54 s).
  • The CLI's own error was lost: it was in Fatalf's multi-line message, and the CI summary keeps only lines with the test-file prefix. Branch dbforward-flake-diagnostics logs each stderr line with t.Logf (test-only), so the next failure names the cause.
LLM

Three more failures today, with the new diagnostics: branch audit-request-path at 688c8e34, branch audit-aws-timeouts at f6d2ea13, and main at 0374ac2e. All shard root@2, about 22 s, and each reran green. From main 0374ac2e:

  • The first raw read (the 20 s slowRestore) completes on the edge-to-console connection 127.0.0.1:43402, accepted at 16:28:38.344.
  • The CLI's request opens its tap connection at 16:28:59.430. The edge answers 997 bytes and then EOF 7 ms later ("upstream side ended after 997 bytes down").
  • The console log shows edge 127.0.0.1:43402: closed by the console at 16:28:59.437, the same millisecond.
  • CLI: "the read of far.example.com's database in region uk did not finish, so nothing was printed", 74 ms after it started.

This looks like a keep-alive reuse race on the edge-to-console hop. The edge reuses its pooled connection from the first long read for the CLI's POST just as the console closes that connection after the streamed response. The POST isn't retried, so the edge returns its error answer (997 bytes). Worth checking why the console closes the connection after the streamed read (an unread request body, or Connection: close on that handler), or whether the edge should not reuse a connection that carried a streamed read.

#1142, which I opened today for the same thing, is a duplicate of this and is closed.

LLM

Root cause found (branch fix-dbforward-reuse-1032, 3b3d2235). It is not the console-side keep-alive race I described above: in every failing CI trace (1e2958cd, 400c86ff, 5db2597f, 4f95eb30, ada520b6) the edge closed its own upstream connection first, 0.5 to 4 ms after the console admitted the read, with "httputil: ReverseProxy read error during body copy: ... use of closed network connection" on the edge's upstream port.

The mechanism, in Go's net/http:

  • After the transport writes a request body's declared bytes upstream, it reads once more to confirm EOF.
  • On HTTP/1.1, the server closes the inbound request body as soon as the response head is written.
  • The console streams its "admitted" line straight away, so under load the edge writes the head before the transport's confirming read. That read gets "invalid Read on closed Body", and the transport closes the upstream connection mid-stream.

This is a real production bug: any POST with a declared body length whose upstream streams at once can be cut, and forwarded db reads are the clearest case.

The fix: the edge hands its transport a body that answers EOF itself at the declared length. A deterministic test fails on the old code. Real carlos db query runs under load went from 3 failures in 400 to 0 in 400, and both e2e tests passed 20 of 20. It is under Astra review now.

LLM

Fixed in main by the merge of branch fix-dbforward-reuse-1032 (the edge's proxied HTTP/1 bodies now end at their declared length). Closing; reopen if TestDBForwardLongRequestThroughTheEdge or TestDBForwardThroughTheBackhaulHop fails again.