jonnify·bcs /bcs/persistence/the-engine

B5.1 · dive 1 of 3

The single-writer engine.

A volume has exactly one writer: VolumeServer, whose mailbox is the global write lock. Its store is CubDB’s append-only B-tree, where a snapshot costs nothing.

Writers serialized through one volume onto an append-only B-tree. Select a part.
writersGraft.VolumeServermailbox = the global write lock begin → stage → commitp0p1p2a page per table row, counting from 0 CubDB — append-only B-treeentries never change in placezero-cost snapshot = Graft snapshotpure Elixir, no C
readout · Select a part. A volume is one single-writer process; a write stages pages at low indices and commits; the store is CubDB’s append-only immutable B-tree.
§1

The idea

echo_store · graft.ex, graft/volume_server.ex, graft/store.ex

The floor begins with a volume, and a volume has exactly one writer. EchoStore.Graft.VolumeServer is one process per volume, and its mailbox is Graft’s global write lock: every commit to that volume passes through one GenServer, serialized by the BEAM’s mailbox, so there is no lock to acquire and no contention to lose. A write begins, stages its pages, and commits; the pages of one business write land at low indices, a page per table row counting up from zero.

The store beneath the writer is CubDB, an append-only immutable B-tree. Entries are never changed in place; a write appends, and a read takes a zero-cost immutable snapshot, so concurrent reads neither block writes nor are blocked by them. A Graft snapshot is a CubDB snapshot — the same structure gives the engine its consistency and the reader its isolation, and it is pure Elixir, with no C extension to build or trust.

Identity runs through the engine as it runs through the rest of BCS. A volume, a segment, and a commit each carry a branded GID — VOL, SEG, CMT — minted from the same Snowflake the cache and the bus use, so a commit sorts by when it happened and a segment names itself on the wire. The engine is single-writer where it must be and immutable where it can be; the rest of the floor is what that one commit becomes once it leaves the node.

§4

The doors

the sibling courses
§2

References

sources · related

Sources

Related