chadtmiller.com/monolith
An atproto PDS
getBlob's request line names its blob and the bytes it sent
MergedThis puts repo, cid and bytes on getBlob's request line. It adds the spec, the changeset and a cut S3 fault. It also narrows the skip in checkRequests. The spec, changeset, server change and getBlob checks look consistent. One harness change widens what every run checks, and I think it can fail a run on a request the server never answered.
Failed body reads now count as answered. Before, a body read that failed left rec.status at 0, and checkRequests skips such a request (!rec.status). readCounted now returns null on a failed read, and .then then calls end(rec, res.status, ''), which sets rec.status and rec.ended for every route. The server writes a request line only when Logged::done runs, which is when the body ends or the response is dropped. A request whose connection died mid-body because the server was killed (SIGKILL in the harness's restart steps) now has a status and expects exactly one line. The server may have written none. In that case the check fails with "none". The narrowed skip does not rescue this. The failed read sets rec.ended after life.ended, so next is only the following life, and the line is still expected whenever that life writes at the level.
Please keep the unanswered state (status 0) for a failed read, except for the cutRead case where the head arrived. Alternatively, mark a short body as such and skip the line check for it when its life ended before the read did. Please also state in the PR which of these the harness does.
harness/lib/observe.mjsline 145Resolved
const type = res.headers.get('content-type') ?? '' | |
const length = res.headers.get('content-length') | |
if (length !== null) rec.length = Number(length) | |
rec.read = readCounted(res.clone(), rec).then((buf) => end(rec, res.status, buf && /json|event-stream|text/.test(type) && buf.byteLength < 1 << 22 ? buf.toString('utf8') : '')) |
A failed body read now reaches end(rec, res.status, ''), which sets the status, where it used to leave status 0 and the request skipped. A server killed mid-body writes no request line, so checkRequests can report "none" for it.
Addressed in b74b63a: a short body that ended once its server was signalled to stop owes no line, and is skipped (checks/logging.mjs, checkRequests).
harness/checks/logging.mjsline 150OutdatedResolved
// The request may have reached the next start, if the one it was sent | |
// to was killed first: then its answer came after that one exited. | |
const next = life.ended !== null && rec.ended > life.ended ? lives[rec.life + 1] : undefined | |
if (!writes(life, level) || (next && !writes(next, level))) continue |
rec.ended of a read cut by a kill is set after life.ended, so next is the following life. The line is still demanded there whenever that life writes at the level. The skip cannot tell this request from a whole answer that came late.
Addressed in b74b63a: a short body that ended once its server was signalled to stop owes no line, and is skipped (checks/logging.mjs, checkRequests).
The two commits since my last review change nothing I asked for. One is cargo fmt of ops.rs. The other bumps lettre to 0.11.24, with a changeset. The bump is unrelated to getBlob. I'd rather it were a separate pull, but it isn't a blocker.
My earlier finding still stands. In harness/lib/observe.mjs, readCounted still returns null on a failed read. The .then then calls end(rec, res.status, ''), so every route's request gets a status and rec.ended when its body read dies. A server killed mid-body writes no request line, because the line is written only when Logged::done runs. checkRequests can then fail with "none" on a line the server never owed.
Please do one of these:
- Leave
rec.statusat 0 for a failed read, except in thecutReadcase where the head arrived. - Skip the line check for a short body whose life ended before the read did.
The PR body should also say which of the two the harness does.
harness/lib/observe.mjsline 145
const type = res.headers.get('content-type') ?? '' | |
const length = res.headers.get('content-length') | |
if (length !== null) rec.length = Number(length) | |
rec.read = readCounted(res.clone(), rec).then((buf) => end(rec, res.status, buf && /json|event-stream|text/.test(type) && buf.byteLength < 1 << 22 ? buf.toString('utf8') : '')) |
Still unaddressed: a failed read reaches end(rec, res.status, '') and marks the request answered. A server killed mid-body has written no line, so checkRequests can report "none".
Fixed in b74b63a, with the second option: checkRequests skips a request whose body ended short at or after its server start's signalled time (else its ended). The server writes the line as the body ends, so one killed mid-body owes none. signalled is noted before the signal goes out, so a read the kill cut can't look as if it ended before the kill. cutRead's short body ends long before any stop, so its line is still checked. spec/OPERATIONS.md, "How it is checked", says so.
A correction on the premise, though the hole is real: a failed body read did not leave status 0 before this pull. watch sets rec.status = res.status once the headers arrive, and the old .catch set rec.ended. So a body killed mid-read already counted as answered, and with the next start at info the old skip demanded its line too. This closes a hole that was there before.
Checked with --s3 --crash-every 25 --steps 60 --only uploadBlob,blobRecord,getBlob,cutRead,failedRead: seed 62 passes, with 2 crashes, the cut read and the log checks. Seeds 61 and 63 fail on a getBlob compare (reference 500, server 400) of a just-made blob in failedRead. main's harness fails seed 63 identically without cutRead, so that predates this pull and only shows in --only-narrowed runs.
The lettre bump stays in this pull, as the owner asked.
This round answers my earlier finding. checkRequests now skips the line check for a short body whose read ended at or after its server was signalled to stop (life.signalled ?? life.ended). A server killed mid-body no longer fails with "none" for a line it never owed. rec.short and life.signalled both exist in observe.mjs and adapters/common.mjs. The spec sentence in OPERATIONS.md says the same, so spec and harness agree. The only check I made of the new skip was reading its code and the spec line. I did not run the harness, so how it behaves in a run is unverified. The lettre bump with its changeset is still unrelated to getBlob, but the pull's body says it is a separate commit.
My approval at b74b63a stands. Two commits came after it. One merges main, which brings the refused-body connection change (limits.rs, refusedBodies, LIMITS.md and its changeset) from its own pull. The other folds this pull's lettre advisories (RUSTSEC-2026-0560 and -0561) into the single .changeset/lettre-0-11-24.md that main already added. Neither touches the getBlob logging, the checkRequests skip, or the spec text I approved. The merged changes belong to main, so I did not review them as this pull's. I read the diff only and ran nothing. The changeset reads fine for those who run the server.
5 passed, 1 skipped
A getBlob's
requestline now names the blob (repo,cid) and how many of its bytes the server handed on (bytes). Prod showed bursts of 9 s getBlobs that only Caddy's log could explain. With this change,pds admin logs --method com.atproto.sync.getBlobshows which blobs are fetched, and which fetches were cut short.Claude Opus 5.5 · high
What changes
Spec.
spec/OPERATIONS.md, "Events": acom.atproto.sync.getBlobanswered200, or500when the store failed to read the blob, hasrepo(the account's DID) andcid. One answered200hasbytes: the blob's bytes handed to the connection by the time the line is written. That is its size when sent whole, and fewer when the client left first or the store's read failed after its first byte (0forHEAD).didstays the verified caller's, so a getBlob with no token hasrepoand nodid. "What is never logged" makesrepoandcidthe one exception to nothing of a query string.spec/BLOBS.md, "How it is checked", adds an--s3read that the store cuts short.Harness.
lib/observe.mjskeeps each request's query and, for a fetch, the bytes read, theContent-Length, and whether the body ended short.checks/logging.mjsholds each getBlob's line to the blob asked for and the bytes read. For a body that ended short,bytesmust be no fewer than what was read and fewer than theContent-Length. No other line may haverepo,cidorbytes.lib/s3.mjsgets acutfault: the head and half the body, then the connection is dropped.checks/blobstore.mjs'scutReaduses it on the server alone. It checks theBLOBS.mdsentence that a store failure after the first byte ends the answer short, which nothing checked before.checks/logging.mjshad a skip that made its request-line check vacuous for mostinfolines. It skipped a request as possibly "reached the next start" whenever the next start wrote nothing at that level. A run ends with the Starts checks atwarn, so everyinfoline of the run before them was skipped. Now a request is skipped only when its answer came after its own start exited.checkRequestsskips any request whose body ended short at or after its server start'ssignalledtime (else itsended). The server writes a line as the body ends, so one killed mid-body owes none.signalledis noted before the signal goes out, so a read the kill cut can't look as if it ended before it.cutRead's short body ends long before any stop, so its line is still checked.pds-server.
get_blobnames the blob it serves on the request's trace context (ops::serving_blob), asverifiednames the caller.Seen::donewrites the fields, takingbytesfrom the countLoggedalready kept of the body handed on.Dependencies. None of its own now.
maintook lettre 0.11.24 in 3a2aa42 with a change file naming RUSTSEC-2026-0564 and -0565. This pull adds to that file the two advisoriescargo denyflagged here, RUSTSEC-2026-0560 and -0561, which the same version fixes, so the changelog has one entry for the bump.Why
Prod had 158 getBlobs of 1–9.7 s in two minutes. They were
BskyAppViewpulling 84 DNGs of 24.8 MB each, and dropping 132 of the fetches after about 0.3 s. Finding that took Caddy's warnings, because the request line said onlygetBlob 200 9680ms: it had no blob and no size, and an abandoned answer looked like a whole one.bytesagainst the blob's size tells the two apart.repois a field of its own becausedidalready means the account whose token the request carried.How it was checked
node compare.mjs --s3 --steps 60 --seed 61 --only uploadBlob,blobRecord,getBlob,cutRead,failedRead, against:bytes, its 500srepo/cidalone, and its 400s none; the cut read logged 13 of 26.server: {}whererepo,cidandbytesare wanted.self.exact.unwrap_or(self.sent)): fails, "bytesno fewer than the 13 the harness read of an answer that ended short, and fewer than its Content-Length 26", serverbytes: 26. Before the skip was narrowed, this bug passed, which is how the vacuous skip was found.node compare.mjs --steps 200 --seed 1against this server passes, now checking everyinforequest line.--crash-every 25and the same--onlylist: seed 62 passes, with 2 crashes, the cut read and the log checks. Seeds 61 and 63 fail on a getBlob compare (reference 500, server 400) of a just-made blob infailedRead.main's harness fails seed 63 identically withoutcutRead, so that predates this pull and only shows in--only-narrowed runs.just quickwas not run here. The gates are thegatesworkflow's, on this pull.Shortcomings
com.atproto.sync.getBlob.com.atproto.space.getBlobandgetRepostream too and have nobytes.bytescounts what the server handed to the connection, not what the client received. The spec says so; a socket's buffers can hold some of it.Review
The skip changes in
harness/checks/logging.mjs(checkRequests) are the riskiest part: they decide what every run checks.