chadtmiller.com/monolith
An atproto PDS
pds migrate-blobs moves blobs between the data directory and a bucket
MergedThis adds pds migrate-blobs --to bucket|disk. It also adds a flock on <data dir>/lock, held by both pds serve and pds migrate-blobs, and a --migrate harness run in the compare gates. I read all 14 changed files and found nothing that must change.
- Spec:
BLOBS.md"Moving them" andCOMMANDS.mddescribe what the code does. That covers the order of steps, the refusals, the{"moved":N,"bytes":B}line, and resuming with the same or the other--to. The README says what is built, not how. The new account-log entry and the marks are internal formats, and the spec doesn't list those for the existing marks or entries either. - Server: the resume cases hold up from the code: killed before the switch, killed after it, then the same
--toor the other one. Theblobstore-movingmark is written first and removed last, andcheck_dirrefuses a directory that has it, including when a power cut lost the mark's bytes. A blob that is missing or doesn't match its CID is collected and named with its DID and CID, and the move stops. The unit tests cover these paths. I found no atproto or MCP crates added and no sign of reference or SDK source being used. - Harness: the checks are strict and compare against the reference. They are refusals beside a live server, usage errors exiting 2, kills at random moments, an object gone, and every blob read as the reference's after each move. I found nothing loosened, and no
conformance.yamlchange.
Two small points in harness/checks/migrate.mjs, neither blocking:
- A run that draws no kill on its first attempts skips the first-kill checks without saying so. Those are the
serveRefusedcheck and the turn-back. stoppedByObjectGonereturns silently when no account holds a blob.
Both depend on the seed. Failing loudly would be stricter, but the pinned seed 71 in the gates already exercises them.
harness/checks/migrate.mjsline 112
killed += 1 | |
// Unfinished, the data directory is not served, whichever way. | |
if (killed === 1) await serveRefused(pick(['bucket', 'disk']), 'on a data directory whose blobs are moving') | |
if (back && killed === 1) { |
The turn-back (back) and the first-kill serveRefused run only if the first attempt is killed. A run whose first attempt isn't killed (a 20% draw, or the move finishing before the kill) passes without checking either, and nothing says so. Counting those checks as ran or skipped, or failing when back was asked for and never ran, would keep a lucky seed from skipping them.
pds migrate-blobs --to bucket|diskmoves a data directory's blobs into an S3 bucket or back out, with the server stopped. It is safe to kill at any point, and re-running finishes the move or reverses it.pds serverefuses a directory mid-move, and the data directory is now held by one process at a time. The reference has no such command; its operators copy files by hand.Claude Opus 5.5 · high
What changes
spec/.
BLOBS.mdgains "Moving them":pds serverefuses the directory and names the command to run.{"moved":N,"bytes":B}.--toto finish, or the other--toto move back.--migratechecks it.COMMANDS.mdlists the command, and sayspds serveandpds migrate-blobseach hold the data directory while they run. A second process exits 1 before writing anything.harness/.
checks/migrate.mjs, the--migraterun, goes in the gates'comparesuite:pds serveandmigrate-blobsmust refuse to start beside a running server, usage errors exit 2, and a move to where the blobs already are does nothing.pds serverefuses the directory, then turns the move back and serves from disk before going on.--s3checks them.crates/.
pds-server/src/migrate_blobs.rs: mark, copy (16 at a time, verified), switch, clean up, finish.blobstore.rs: theblobstore-movingmark, andpds serverefusing it.store::hold: aflockon<data dir>/lock, taken by both commands before anything else.blobObjectsDeletedfor a move out of the bucket.pds/src/main.rsdispatches the command.Why
Without it, a data directory could never change where its blobs are kept. The reference's way is a manual copy and a restart, and it starts on a half-copied bucket without complaint, serving
500for every blob missed. This command checks every blob before switching, and the lock closes an older gap: twopds serveprocesses could share one data directory.How it was checked
--migratefailed against the server before this change: a secondpds servestarted beside a running one.pds servestarting on a directory mid-move ("pds serve on a data directory whose blobs are moving differs").--migrateat seeds 71 and 3 (killed mid-move up to 3 times, turned back),--steps 400 --seed 61 --crash-every 25 --s3and--steps 600 --seed 51 --crash-every 40 --storeall agree.--steps 400 --seed 24 --crash-every 15 --firehoseand--upgrade, withcargo test -p pds-server(335 tests) and clippy clean. fmt is clean.Shortcomings