Repository navigation
Conversation
A layout.convert job per collection walks its versions in order, from a cursor
(version, record tree, key) within a budget, and writes the records each
version's new leaves hold into the collection's F packs and index, as stored.
Nodes don't change, so version hashes don't. A record is written once however
many versions hold it, and a job run again writes nothing twice (convertTree
writes only what KeyedLayout.missing finds absent). Versions committed while it
runs are converted in turn; the merges of its index run as it goes
(layout.maintain with layout 'f').
Once the head is converted it switches the collection to F in one statement,
only if the head is still the last version converted and no push is
committing. A commit reads the layout when it starts and keeps it (a parallel
commit in its plan, which its units and assembly open), and publishes only if
the collection is still in it (publishVersion's recordLayout); otherwise it
fails with 503, push again. Commits wait 90 s after the switch, as isolates
note a collection's layout for a minute.
POST /api/admin/convert {collection} starts it; GET ?collection= its state.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 2 of layout F (planning: layout-f-pr.md, "PR 2"): a job that converts an existing collection from today's layout (leaf bodies) to F (packs and an index per collection and set).
How it works
POST /api/admin/convert {collection}(stewards) starts alayout.convertjob;GET /api/admin/convert?collection=reads its state.newNodes), reads every new leaf's body (today's layout), and writes the records F's index doesn't yet hold into the set's packs, as stored. An out-of-line record stays a pointer. (convertTreeandversionTreesin@underlay/protocol.)KeyedLayout.missingreads the newest manifest).layout.maintainwithlayout: 'f'opens F whatever the collection's layout.The switch
When the head is converted, one statement moves
record_layouttof, but only if the head is still the last version converted and no push of the collection is committing. Otherwise the job tries again in 30 s.So that no version is ever published in a layout the collection isn't in:
stores.forget) and keeps it. A parallel commit records it in its plan, and its units, assembly and validation open the collection in that layout (stores.forCollectionAs).publishVersionpublishes only if the collection is still in the commit's layout (recordLayout). A commit that finds it changed fails with 503, push again (LayoutChangedError).LayoutSwitchingError, 503). Until then no version only F can read appears while an isolate may still read in today's layout.Not here
Tests
test/convert.test.ts:Protocol 258 and server 574 (both layouts) pass.
Deploy
No migration. Both Workers. Before
crossref-demo/works(110.7M records), size its bodies by prefix and try it on a smaller collection on staging.