chadtmiller.com/monolith
An atproto PDS
pds-server: imported records keep their blocks through the log
MergedThis keeps an imported record's exact block through the log. A put holds the record's JSON when that reads back as the same block, and the block in hex when it doesn't. The spec pages, changeset and tests for both the account and space import paths are there. I found one reader of log puts that the change missed.
crates/pds-server/src/checkpoint/unmarked.rs (replay, in the records closure) still reads each space put with from_json(value). A put that put_value wrote as a hex string is not an error there. from_json returns V::Str, cids_in then finds nothing, and unwrap_or_default hides it. Replaying the log therefore drops the blob refs of every such record from the space repo's blob counts. These are the records this pull is about, a ref that is a one-key $link map.
Please read the put there with put_record(value).map(|r| cids_in(&r.value)), as blobs.rs now does. Add a check that a space import with such a ref, replayed from the log with no mark, still lists the blob. The new space test may not reach this path, so I couldn't tell whether it covers it.
Done in 0f-the-latest push: checkpoint::unmarked::replay reads each space put with put_record(value).map(|r| cids_in(&r.value)). checkpoint::unmarked::tests::a_put_of_a_block_references_its_blobs replays, as before the mark, a space import and a space commit whose put holds the block of a record with a one-key $link ref, and checks both list the blob; with the old from_json read planted back it fails (left: []). Entries before the mark are an older version's, which never wrote a block, so a real log reaches this only through a downgrade and upgrade; the read is the same as everywhere else all the same.
The one reader I flagged is fixed. unmarked.rs replay now reads each space put with put_record(value).map(|r| cids_in(&r.value)), so a put held as a hex block still counts its blob refs. The new test a_put_of_a_block_references_its_blobs replays both an import entry and a commit entry holding such a put with no mark. It checks that each record's blob is listed. That is the check I asked for. I read only the diff since my last review. I found nothing else wrong, so I approve.
Carried forward: the change this pull makes at 624f72121743de4339e2100758170e3232667482 is the one reviewed at 7667d70e775b45d91c1aab7edff7ba77430fe18b, so that review stands. What is new comes from its base.
Ejected batch (57117b9) failures, rerun alone here on this pull's build with main merged in (624f721): compare.mjs --migrate --seed 71 passes, twice (all migration checks agree; on the runner migrate-blobs --to disk answered moved 0 against the reference's 37 at attempt 3 after 2 kills, which did not recur); compare.mjs --steps 600 --seed 51 --crash-every 40 --store passes (all 600 steps agree; on the runner it was the start-time bound, 445 ms against 388 ms, every step agreeing, the same limit another unrelated pull hit and passed on rerun). The --pages failure, a passkey sign-in's view, touches nothing this pull changes. Queued again.
3 passed, 1 skipped
An account moved in with
importRepofrom a PDS that wrote blob refs as{"$link": "<cid>"}maps (pds.js did, in 3,572 of the owner's 24,342 records) left its log unreadable:store failureon the import and every write after, no compaction, and the server stopped the first time it read such a record from the log. This keeps every imported record byte for byte at the CAR's CID.Claude Opus 5.5 · high
What changes
The log. A commit's entry in an account's log held each record it put as its JSON (
to_json), read back withfrom_jsonwhen the log is replayed, verified, compacted, or a record's block is read from it. A put now holds the record's JSON where that reads back as its block, and otherwise the block itself, in hex (pds_repo::put_value,put_block,put_record): a record is a map, so a string is never one's JSON, and logs written before read as they did. A space repo's commit and import entries hold their records the same way.Blob refs. A blob ref whose
refis a map of the one key$link, a CID string, references that blob, as JSON reads it (blobs::blob_ref). The account's blob counts were already made from the JSON, so for an account's import this is what the server did; now it is the same whether the record is read from memory, the log or a restart, and for space repos too.The spec.
MIGRATION.md, "importRepo": each record is the CAR's block, byte for byte, at its CID, though JSON would write it as another.BLOBS.md, "Blob refs in records": such a one-key$linkmap as arefis taken as the link.SPACES-EXPORT.mdalready said a space repo's records are kept "as their bytes".Why
The root cause is
crates/pds-repo/src/lib.rs:644(andfull.rs:463), which loggedto_json(&r.value), andcrates/pds-server/src/checkpoint.rs:1172and:1392(andfull.rs:315,blobs.rs:615), which read it back withfrom_json. The data model's JSON is not one-to-one:from_json(crates/pds-repo/src/data.rs:294) turns any object of the one key$linkinto a link, and any$bytesobject into bytes. A record decoded from a CAR may hold such a map: pds.js wrote blob refs'refas{"$link": "<cid string>"}maps rather than CID links, and in the owner's repository 3,572 records do so, naming 6,124 blobs. Read back, such a record was a different block with a different CID, so compaction refused the log ("record app.bsky.actor.link/3myidfniwhkqd, which the commit … does not sign", the first such path in key order), and reading the record from the log stopped the server ("cannot recover … block … is not what its frame holds"). MST prefix compression, the first lead, has nothing to do with it.Writing every put as its block would have changed every log entry and every reader for a case most records never have; refusing such records would have refused the owner's repository, which the spec says is taken. Not counting such a
refas a blob ref would have dropped 6,124 of the owner's blobs after the move.How it was checked
migration::tests::imports_keep_each_record_as_its_block: an import of records holding a one-key$linkmap as a blob'sref, a$bytesmap, and a$linkthat is no CID; each must be held at the CAR's CID as its bytes, read back after the log is compacted into a table and from that table, ingetRepo, and through a restart, with the blob listed bylistMissingBlobs. Onmainit fails as the owner's import did:compacting …/repo.0.log: record a.b.c/bytes, which the commit … does not sign, thencannot recover …: block … is not what its frame holds.space_repo::tests::imports_keep_each_record_as_its_bytes: the same forcom.atproto.space.importRepo, from the log, the table and a restart.log::tests::bad_entries_are_refused,migration::tests::imports_are_checked_and_whole,space_repo::tests::whole_repos_and_imports, andpds-repo's tests, unchanged and passing.main(4409a5c) the samestore failureand then the stop; on this branch, no store failure.Shortcomings
just nightlywas not run here; thenightlyworkflow runs it onmain.$linkmap in an imported record is not compared: the harness writes no such CAR.Review
Start at
put_valueincrates/pds-repo/src/lib.rs, thenblob_refincrates/pds-server/src/blobs.rs.