Boulton and Watt steam engine of 1784: flywheel, beam, and centrifugal governor.

Sounding Works · design

PinionDB

A strongly consistent key/value database. Small, often very fast. Not shipping yet.

Status

Early, and we mean it

PinionDB is in design. There is no crate, no download, no hosted service. The specification is being finished; formal proofs in P and TLA+ come next. Apache-2.0 when the code lands.

Two jobs, and only those two, until they are actually true:

  1. A Dynamo-shaped data API. Scan, Query, Filter, conditionals, Transact. And full ANSI SQL, not DynamoDB PartiQL wearing a SELECT.
  2. Tight read and write tails on current metal. DMA, NUMA, cache lines, 4K-aligned NVMe. The data structures and the cluster coordination are written for that hardware, not around it.

The lineage is honest: FoundationDB, the original Dynamo paper, TigerBeetle. We like those machines. PinionDB is not a wrap of any of them.

The picture

Streams spin the cache

Visualise a key/value store as a pinion. Writes travel as a stream: a write-ahead log, quorum persisted on the hosts, then published into memory. That memory is the live read view. It is not a second, weaker database. Restart an empty RAM, replay the log, then serve.

Cores own partitions. Hosts vote. Scale-out is more pinned cores, not a bigger replica factor you type into a config file. Replica factor N is odd; ACK is quorum. There is no “laptop profile” that ACKs in RAM and a different one for production.

The WAL is the source of truth. B-tree pages on a 4K DMA device are a checkpoint. Gossip copies of the cache exist for locality. They are not the write quorum. Losing a gossip copy must not lose a write that already committed.

Reads catch up; writes pin. A Get, a Query, or a SQL fragment is served from a replica that has applied the log, not from the write primary as a shortcut around catch-up. There is no consistency knob.

Two languages

Items, and SQL

The engine speaks keys and documents. Hash key, optional sort key, table id on every op. Put is a typed document, not a bag of bytes. Query is a prefix walk with a filter. A Transact is one or many items, ceiling 100, unpublished together, one Commit.

That surface is meant to cover the DynamoDB data API: Get, Put, Delete, Update paths, Query, Scan, conditionals, transact. It does not speak Amazon’s HTTP, SigV4 service code dynamodb, or PartiQL. Fronts that want Dynamo-shaped strings compile them onto the engine types before the call. The engine never sees a Dynamo string.

SQL is native. DataFusion plans it. Ballista scatters and shuffles when more than one owner is involved. Indexed WHERE pk = ? is a Query. Unindexed Scan is scatter. Mutations collect identities, then Transact. SQL is not a planner on the write ACK path, and it is not a second database over a lake catalog.

Contracts

Read-after-write, or it is not PinionDB

Strictly serialised on each object. A successful Get is the latest committed Put, Delete, or Increment. Concurrent conflicting writes: at most one success, the rest Conflict. Last-write-wins by wall clock is forbidden.

A write does not ACK until unpublished records are on a majority of N, the coordinator has persisted Commit, and every item-owner has published metadata. Send completion is never the ACK. Kernel TCP is never the ACK. Waiting on B-tree page persist is not the ACK either (ARIES no-force). Sub-millisecond is a cache-hit Get, an OCC Conflict, or an idempotent replay of the same session op.

Failure is named: Conflict, Isolated, CeilingExceeded, KeyNotFound, SystemFailure. If the partition primary is unreachable, the engine fails closed. It does not hand you a cached value it cannot prove.

Hardware

Written for the machine in the rack

One owner process per NUMA node, pinned. Record headers are 64 bytes, one cache line. Pages are 4K, O_DIRECT. Arena prefers HugePages. Not malloc-per-Put. SPDK is preferred for the WAL device; io_uring and kernel TCP are autotuned fallbacks for replica bytes, never a second ACK story.

Simulator, laptop, and production metal run the same owner code. I/O is injected. cargo test uses a fake log. Live SPDK is not the correctness gate.

Paper

The spec is the product, for now

Chapters cover guarantees, the engine types, 64-byte layout, WAL, indexes, SQL, write/read, cluster, datapath, metering, a closed MUST NOT list, and a deterministic simulator. An implementation that satisfies those MUSTs and is green under the verify chapter is PinionDB. Code without a deterministic test for a MUST is not.

Working title used to be SkipprDB. Same engine. New name, same contracts.

Specification on GitHub Sounding Works

Boulton & Watt steam engine, 1784. Robert H. Thurston, 1878. Public domain. Massey’s sounding machine below. Popular Science Monthly. Public domain.

Massey’s sounding machine, a compact brass instrument with twin depth dials and a rotor.

Fewer moving parts

One engine, one ACK

No eventual-read flag. No RAM ACK for the laptop and a durable ACK for the rack. No second SQL product sharing this planner. Queue shapes stay out. Object archive is PITR, not the Get path.