chadtmiller.com/monolith
An atproto PDS
0
0
Blobstore connections kept 90 s; a request failed on its way sent again
Merged Approved
This pull keeps blobstore connections for 90 s and sends a request that failed before any answer once more over a connection of its own. I found nothing that must change.
- Server:
Bucket::sendsends over the pooled client. It repeats over the no-pool client only for errors that are neither connect nor timeout errors, and only when the request body clones. The retry runs inside the existingtokio::time::timeoutat each call site, so the time limit stays as the spec says. - Spec and changeset:
BLOBS.mdand the changeset describe the behaviour, and the harness steps are named under "How it is checked". - Harness: the new steps tighten the suite and loosen nothing. The existing
failedUploadandfailedReadchecks use unlimited failure rules, so a retry still fails and they should keep passing. I did not run them.
I did not check whether docs/guide/ mentions the 2 s idle timeout.
All checks have passed
4 passed, 1 skipped
1 skipped check
releaseSkippedMerged as 77b758e
In production, the server's blobstore requests to R2 averaged 162 ms across 13,141 requests. The bucket client dropped idle connections after 2 s, so most requests paid a new connection and TLS handshake: from the box, 75–110 ms on a new connection, 26 ms on a reused one. This keeps connections for 90 s, and sends once more over a new connection a request that failed before any answer.
Claude Opus 5.5 · high
What changes
Spec.
BLOBS.md, "Requests to the store": a request goes over a connection an earlier one left open, and the server keeps one unused for up to 90 s. Every request to the store can be made twice to the same effect (aPUTof the same bytes to the same key, aGET, aDELETE). So a request that fails on its way, the connection closed before any answer came, is sent once more over a connection of its own, within the same time limit. Only one that fails so twice, or one the store answers and then fails, fails as "The objects" says. Two new entries under "How it is checked".Harness.
lib/s3.mjsrecords which connection each request came on. Two new--s3steps:resetOnce: the store resets each side's first read of a referenced blob, once.getBlobis compared, and both sides must answer200with the blob whole. The reference retries too.keptConnection, on the server alone: twogetBlobs 3 s apart. That is past the old 2 s idle timeout and within the store's 5 s keep-alive. The second read must go over the first one's connection.pds-server.
blobstore::Bucketholds a pooled client (90 s idle) and a client that keeps no connection.Bucket::sendsends a failed request again over the second one, unless it failed to connect or timed out. All three ways of sending (exchange,get,fetch) go through it.Why
pds_outbound_request_duration_seconds{target="blobstore"}on monolith.chadtmiller.com averaged 162 ms. Only 162 of 13,141 requests took under 50 ms.getBlob's median there is 96 ms. The 2 s idle timeout guarded against a store closing a connection just as a request goes out on it. Sending once more over a new connection handles that race, and keeps connections between requests.How it was checked
main(itsblobstore.rsbuilt apart):resetOncediffers (reference200, server500), andkeptConnectionfails (connections 1 then 3). With the change, both pass:--s3 --only resetOnce,keptConnection.cargo test -p pds-server --lib -- blobstorepasses.just quickpasses here (all 7 runs, the--s3crash run among them);cargo test -p pds-server --lib -- blobs:: migrate_blobspasses.Shortcomings
outbound.rs, forwarded requests anddid:webdocuments) still keeps idle connections for only 2 s. A forwardedPOSTcannot safely be sent twice, so it needs a different answer than this one.PUTa second time. That is the same object, and costs one more request.