Changelog and roadmap

Roadmap

What is done, in progress and planned, as the stage tracker and the implementation plan state it.

This page reproduces the stage tracker and the implementation plan. Nothing here is a promise of a date.

Summary#

  • Done items are marked [x] in the stage tracker: the research and benchmark crates of S0, the collection store of S1, the server and wire protocol of S2a and S2b, filters over the network and indexes of S3, Studio ST0 to ST2, asynchronous and synchronous replication (D38, D39). The later status lines of the plan record what was built afterwards: automatic failover (D42), the storage engine raftdb-lsm and server tables on it (D43, D46 to D49), the zero-flag first run and install-service (D44, D45), the watcher quorum and table groups (D50, D51), partitioned tables (layer 2), and the MySQL and MariaDB front-ends (D52 and later). The changelog has the details.
  • In progress is marked (in progress), (started) or [~] in the tracker: S0, S1, S3 and S2d.
  • Planned items are marked [ ]: for example S2c, the other stages of S4 to S10, the very large database work (section 5 of the plan), hardware acceleration (section 7), HTTPS webhooks, more client languages, TLS between nodes.

The stage tracker was last written before many of the later entries of the changelog; where its text and the plan's status lines differ, the status lines of the plan and the changelog are newer.

Stage tracker#

S0 Research and benchmark harness (in progress)#

Target: byte-cost notes for 12 systems, benchmarks run in CI.

  • Cargo workspace, toolchain, lints (unsafe only in the allocator shim and raftdb-table, each use has a SAFETY note)
  • raftdb-core: numeric targets shared with the harness
  • raftdb-bench: counting allocator, HdrHistogram latency, JSON reports, targets
  • First study 00: hash table byte cost (slab layout reaches 10.49 B/entry)
  • CI workflow (fmt, clippy, tests, small benchmark smoke run)
  • Study 01 Dragonfly Dashtable read from source; raftdb-table built from it (8.75 B/entry, 15-17M reads/s, 21M with prefetch, fuzz-tested)
  • Studies 02-04 (Redis, SQLite, BSON) read from source; raftdb-doc built (111.7 B/doc = 0.44 of JSON, 29.6M field reads/s, forbid(unsafe), corruption-fuzzed)
  • Study 06 DuckDB read from source; raftdb-exec built (67M docs/s on 6 threads over 223 MB vs 50M target; plan cache hit 0.03 us vs 5 us)
  • Documentation standard enforced by lints, decision log, changelog, per-crate docs
  • Study 07 PostgreSQL WAL read from source; raftdb-wal built (305,903 durable records/s vs 300k target, ack p99 1.06 ms vs 2 ms, recovery 1.49 GB/s vs 1 GB/s)
  • Study 05 Seastar read from source; raftdb-spsc built (ring 319M msgs/s vs 15M target; routed reads 41.6M/s vs 2M target; idle connection model 72 B vs 2 KB). Per-core allocator and real sockets are Stage 2 work.
  • Portability pass (owner rule): portable implementations everywhere, optional x86 fast paths with equivalence tests, portable feature, byte-exact format tests
  • Linux x86_64 tests and clippy: 130/130 default, 130/130 portable, lint clean (2026-11-09, commit 16f5de4: server, databases/tables, SQL, accounts, indexes; earlier 38, 51, 77, 104)
  • Linux benchmarks on a quiet host; macOS and ARM (aarch64) runs before release
  • Study 08 RocksDB read; raftdb-bloom built (0.97 % false positives and 1.25 B/key at 10 bits/key, 71.9M absent-key checks/s; compaction not read)
  • Study 09 InnoDB vs PostgreSQL versions read; raftdb-mvcc built (12-byte version header, 495M visibility checks/s typical, 183M worst case)
  • Study 10 FoundationDB simulation read; raftdb-sim built (1M crash schedules, 0 violations, planted bug found in 104 schedules, 5,042 schedules/s)
  • Study 11 Raft libraries compared from source: own Raft core in the raft-rs shape (no spike run; TiKV multi-Raft still to read)
  • Reference machine fixed (Linux, NVMe, 16 cores) and baselines re-run there
  • Competitor baselines scripted: PostgreSQL, Redis/Dragonfly, MongoDB, RocksDB, DuckDB
  • Running Raft spike / TiKV multi-Raft reading before S9 (study 11 decided from source only)
  • Owner answers to the open decisions (Section 8 of the requirements)

S1 Collection store (started)#

  • raftdb-store: key -> document over one arena + raftdb-table (15.7 B/entry, 5.97M windowed reads/s; first layout missed the read target and was redesigned)
  • Scan interface: Docs trait in raftdb-exec, Collection::snapshot() (59.7M docs/s on 6 threads over a collection)
  • raftdb-schema: strict types, required/nullable, ranges (3.16M docs/s validated, target 3M)
  • raftdb-db: schema + log + collection + replay; pipelined durable inserts 3.43M/s (target 300k), restart replay 3.23M records/s
  • Ack p99 <= 2 ms at 300k/s FAILS on the dev PC (6-14 ms; p50 0.70 ms; machine stalls of 5-29 ms): re-run on the Linux reference host; design fallback documented
  • Storage trait in raftdb-wal; whole-Table crash simulation (30,000 schedules clean)
  • Schema persisted in the log; Table::checkpoint (3.79M docs/s, log halves, restart 503 -> 315 ms)
  • Incremental checkpoint without a write pause, log rotation, directory sync after rename; unique keys and relations (S5); secondary indexes; MVCC headers; S1 target run on the Linux reference machine

Studio (parallel track)#

Plan: the Studio plan (approved 2026-11-09).

  • ST0: the API design document (DRAFT contract), the wireframes, the design tokens
  • ST1: file viewer (JSON/NDJSON/CSV, streamed; table/tree/raw; filter; export): 207 Node tests, 100 MB NDJSON first rows in 4 ms (target 2 s); shared filter conformance file passes in JS and Rust (119+28 cases). Checked by hand once in Chrome; Firefox/Safari, file picker/drag-drop, high-contrast theme, screen readers NOT verified
  • ST2 (connect to servers): Studio rebuilt as an SSMS-style Object Explorer (left tree, right Properties/Data/Query tabs), several server connections at once, user/password and token login (nothing secret is stored), New Database / New Table dialogs, lazy virtual grid with row count, SQL tab with error marking, import and export wizards, view and edit modes with confirmations; 265 Node tests. Checked by hand in Chrome against running servers (two connections, wrong and right password, create database and two tables, 2,500-line import with one bad line, 120,000-row lazy scroll, SQL error position). NOT verified: Firefox/Safari, token login in a browser, column chooser and export by clicking, per-connection logout, screen readers
  • Next: owner review of the Studio; cross-server connections need CORS (below)

S2 Server (design done, S2a built)#

Design: the Stage 2 design document (thread-per-core shards, portable poller with optional epoll/kqueue/IOCP, own binary protocol).

  • S2a raftdb-proto: frame + message codec, 49.9M messages/s (target 20M), corruption-fuzzed
  • S2b raftdb-server: thread-per-connection reference server, shard + flusher threads, test client; loopback: 5.56M reads/s (target 2M), 1.21M durable inserts/s (target 300k). Latency (ack p99 over the network) not yet measured
  • S2c Linux epoll fast path; 1M idle connections on the Linux reference host
  • [~] S2d Admin HTTP for the Studio (ST2): JSON API subset + static files + raftdb-server binary done (5 tests); WebSocket, TLS, users/roles, explain, cursors resource not done

S3 Filters over the network (started)#

  • Databases and tables (server catalog), SQL subset to plan (S6 first slice), accounts with password login, bulk import (2026-11-09; see CHANGELOG)
  • SQL ORDER BY / OFFSET (sorted queries 24.8/s for the top 100 of 1 M rows; deep pages 0.9 s: two-step fetch is the open improvement)
  • Drop / rename database and table (confirmed by exact name; default database and table protected)
  • Server-level checkpoints (at start when a log is mostly history; on demand over HTTP)
  • Roles (readonly/readwrite/admin) optionally limited to one database
  • Compaction while serving (needs MVCC), per-table grants, column types, TLS, SQL: LIKE, GROUP BY, writes
  • Field-name registry across shards; JSON in (PutJson) and out; filter count and cursor-paged results over all shards
  • Target: filter scan 57.2M docs/s over TCP (50M); first versions failed it at 37.2M and 40.5M (fixed by a cached scan list and a parallel scan inside the shard; page requests went from 9.5 ms to 0.46 ms)
  • raftdb-index: secondary index structure (12 B/entry, 2.23M lookups/s, 1.44M updates/s); NOT yet used by queries
  • Index wired into raftdb-db, the executor path and the server: CreateIndex, planner over required comparisons, maintained on writes, in log + checkpoint; indexed point query 12.7k/s vs 163/s scan (target 10k/s)
  • Multi-field / nested / array indexes, order-by through an index, dropping indexes, persisted index runs (rebuilt at open today); SQL front end (S6) to the same plan; sort order; snapshot-consistent paging (S5); plan cache in the server; Studio ST2 (needs S2d)

S4 .. S10#

  • S9 first slice (2026-11-09, D38): asynchronous log-shipping replicas (read-only, byte-identical logs, resume, resync after checkpoint, manual promote)
  • S9 synchronous commit option (--sync-replicas, timeout fallback; D39)
  • S9 next: automatic failover (Raft), replicate accounts, rename as rename, multi-master later

Other stages not started (S4 pieces exist: log, group commit, checkpoint). See the requirements document, Section 6.

Implementation plan#

The plan document begins with "Status: plan only, nothing here is built yet." Several of its sections have since been built; the status lines inside the sections (dated) say which, and the changelog lists them.

Status: plan only, nothing here is built yet. Order of work follows the dependencies: automatic failover (in progress) comes first because accounts and multi-master build on it.

0. Prerequisite: automatic failover (in progress)#

Raft elects the primary; the existing log shipping (D38) moves the data. A candidate's vote rank is (epoch, durable log offset), so a node that holds less data cannot win. Writes are acknowledged only after a follower confirmed them (strict sync). Tested as 3 server processes on test server A: kill the leader, measure takeover time, check that no acknowledged write is lost.

1. Replicating accounts#

Today: accounts come from --user / --token on the command line of each server. Nothing is stored, so in a cluster every node must be started with the same list or a client logs in on one node and not on another after a failover.

Plan

  1. Store accounts in the database (system database _system, table accounts): name, salted password hash (PBKDF2-HMAC-SHA256 from the existing sha.rs, no plain text), role, database scope, created/changed time. Command-line accounts stay as a bootstrap (first admin) and are merged in, never overwritten.
  2. Admin API: POST/PUT/DELETE /v1/accounts, GET /v1/accounts (no hashes returned), audit line per change.
  3. Replication: _system is an ordinary table, so log shipping copies it to replicas byte for byte. The replica login check reads the replicated table (cache invalidated on every applied record), so a promoted node already has every account. The replication credential itself is an account with a replicate role.
  4. Tokens: same table, kind = token, hash only.
  5. Tests: create on primary, log in on replica; change password, old one refused on both; promote, login still works; account change during a failover is not lost (acknowledged = on a majority). Connector conformance gets scenarios 25-26 (login after failover, password change).
  6. Docs: server document, security section; migration note for --user users.

Effort: about one stage (small). Risk: password hashing cost on the login path (cache the verified result per connection, not per request).

2. Multi-master#

Decision first (needs your input): "multi-master" can mean three things with very different cost.

OptionWhat it givesCostConflicts
A. Raft per shard group, leaders spread over nodesEvery node leads some shards, so writes scale and no single primary. Strongly consistent.Large: needs Raft replication of the data log (not just election), shard-to-group routing, cross-shard transactionsnone (single leader per key)
B. Active-active with conflict resolution (last-writer-wins or CRDT-style per field)Writes accepted anywhere, even while partitionedLarge: version vectors per document, merge rules, tombstonesyes, resolved by rule, may lose a write
C. Keep one primary, any node accepts writes and forwards themSimple for clientsSmall, but it is not real multi-masternone

Recommendation: C as a first step (clients can talk to any node), then A. B only if offline/partition writes are a requirement, because it changes the guarantees (a write can be silently overwritten).

Plan for A

  1. Extend raftdb-raft with log compaction and snapshots, membership change (add/remove node), read index for linearizable reads.
  2. Replicate the table log through Raft (the committed Raft entry is the WAL record), replacing sync-replicas for those tables; followers apply committed entries.
  3. Shard groups: N groups (default = shard count / k), each its own Raft group, a placement table in _system.
  4. Router: any node accepts a request and forwards it to the group leader (this is also option C).
  5. Cross-shard writes: keep single-shard atomicity; multi-shard batches go through two-phase commit with a coordinator group, or are refused with a clear error in the first version.
  6. Test: the deterministic simulator extended to the whole cluster (partitions, crashes), then a Jepsen-style check (linearizability of single-key operations) on test server A with 3 processes, then a real multi-VM run.

Effort: several stages. Not started until failover is proven.

3. HTTPS webhooks in the watcher#

Today: webhooks are plain HTTP only; notify_command plus curl is the workaround. The engine crates have no dependencies and no TLS.

Plan

  1. Keep the zero-dependency rule for the engine; raftdb-watch is a tool, so it may have a dependency. Add a Cargo feature https (off by default) that pulls rustls with the ring provider and webpki-roots, a vetted library rather than hand-written TLS.
  2. In notify.rs: https:// URLs use a rustls::StreamOwned over the existing TCP code; same timeouts (connect, write, read), same 30 s total limit, redirects not followed.
  3. Config: notify_webhook = https://..., optional notify_ca_file (private CA) and notify_header = Authorization: ... (secret read from a file or environment variable, never logged).
  4. Ready-made payload adapters: Slack ({"text": ...}), generic JSON (current format); Teams and others later.
  5. Tests: a local TLS test server (self-signed CA created by the test) for success, bad certificate refused, timeout, error status; --test-notify works for HTTPS; the plain build still compiles without the feature.
  6. Docs: watcher operations document, security notes.

Effort: small, one stage.

4. Languages without a client library#

Today: 14 languages ship, each only after all 24 conformance scenarios pass on a running Raft DB server. Missing: Swift, Haskell, Julia, Tcl, Nim, Zig, Crystal, Erlang, F#/VB (use the C# library), Objective-C, COBOL, Fortran and others.

Plan

  1. Group by what is realistic:
    • Use an existing library: Kotlin, Scala, Clojure, Groovy (Java library); F#, VB.NET (C# library); Objective-C (the C library).
    • Write a native library, test on test server A (toolchain installable with apt): Julia, Tcl, Nim, Zig, Crystal, Erlang, Haskell, Swift (Linux toolchain).
    • No test toolchain here: write nothing; the HTTP/JSON API is the documented route.
  2. Generate part of the work: a small spec-driven generator produces the framing, the error table and the scenario test skeleton from the connector specification, so a new language is mostly the socket and JSON glue.
  3. Order by demand: Swift (mobile), Julia (data), Erlang, Haskell, Tcl, Nim, Zig, Crystal.
  4. Same acceptance rule as now: 24/24 on a running Raft DB server (plus 25-26 after section 1), README row, example, run-tests.sh.

Effort: about half a day per language once the generator exists.

Suggested order#

  1. Finish and prove automatic failover (running now).
  2. Accounts replication (small, needed for a real cluster).
  3. HTTPS webhooks (small, independent).
  4. Choose the multi-master option, then build C and A.
  5. More languages in parallel with the rest.

Update 2026-11-09#

  • Multi-master: the owner chose option A (Raft groups per shard group, leaders spread over the nodes).
  • Automatic failover (section 0) is built and verified (D42). It is the interim design: one primary, Raft elects it. Option A replaces it by putting the data log itself through Raft.

5. Very large databases (up to a petabyte)#

The owner's direction: reach petabyte scale by applying big-data techniques inside Raft DB. A petabyte is not one machine, so the work is scale-out first, then per-node efficiency. Honest state today: Raft DB is a fast single-node engine with whole-copy replicas and now automatic failover. It is not a VLDB: all data of a table lives on every node, a node's log is one growing file per shard, a checkpoint rewrites a whole log, start-up replays the log (so recovery time follows data size), and there is no tiering, no backup/point-in-time recovery and no distributed query. None of the items below is built; each stage has a measurable target.

What "VLDB-ready" means here (checklist, each item gets a test or a measurement):

#CriterionTechniqueTarget
V1Data spread over many nodes; no node holds everythingPartitioned shard groups (hash and range), placement table, router (this is multi-master option A)N nodes give about N times the writes/s and capacity in a scale test; adding a node moves only ~1/N of the data
V2Bounded recovery timeSegmented log (fixed-size segments), checkpoints that write new files instead of rewriting, snapshot + log tail on restart, Raft snapshots and log compactionRestart time stays flat from 1 GB to 1 TB per node
V3Cost and speed at any age of dataTiered storage: hot (NVMe), warm (HDD/cheaper), cold (object storage); time/range partitions move down automatically; tier-aware readsQuery on hot data unchanged while cold data grows 100x
V4Fewer bytes read and storedCompression per block (dictionary, LZ-class, delta for numbers/timestamps), columnar blocks for analytic scans, zone maps/min-max per block, bloom filters per segment (D14 exists)Scan throughput and storage ratio measured on a benchmark dataset
V5Queries that skip data and use many cores/nodesPartition pruning, secondary-index partitioning (local and global), parallel scan, distributed query (scatter-gather with partial aggregation), cost-based planner with statisticsFilter on the partition key touches 1 partition; count over N nodes scales with N
V6Writes keep up while data growsLSM-style compaction in the background with write throttling and bounded write amplification, bulk load that builds files directlySustained write rate does not fall as data grows 100x
V7Online operationsOnline schema change, online rebalancing/split/merge of partitions, rolling upgradesNo write outage in a test that moves a partition while a load runs
V8Backup and recovery at scaleIncremental backup from log shipping, point-in-time recovery, parallel restore, cross-region replica, restore drillsRestore of a large dataset within a stated RTO; PITR to a chosen second proven by a test
V9IntegrityChecksums on every block, background scrub, repair from a replicaInjected bit flips are found and repaired
V10ControlPer-tenant quotas, query memory/time limits, admission control, metrics and the watcher for every nodeOverload test: the database degrades but does not fall over

Order: V2 first (without bounded recovery nothing else is safe), then V1 together with multi-master option A (they are the same work), then V6, V4, V3, V5, V8, V9, V7, V10.

How a petabyte is proven without a petabyte of hardware: a single node is tested up to the largest dataset the test machines can hold (a few TB on a large cloud disk), and the numbers that must stay flat are recorded as the dataset grows (restart time, p99 read/write latency, write amplification, compaction debt). Scale-out is tested with 3, 6, 12 nodes and the per-node figures must not change. The petabyte capacity is then a calculation from measured per-node limits and measured near-linear scale-out, stated as such, never as a measured petabyte. A real multi-hundred-terabyte run needs the owner's cloud budget and is a separate decision.

Deliberately not promised: one machine holding a petabyte; transactions across partitions in the first version (single-partition atomicity first, two-phase commit later); sub-second restore of a petabyte.

Placement and redundancy (owner's direction 2026-11-09: no node holds everything; at least 3 copies or a better scheme)#

  • Partitions, not whole copies. A table is cut into partitions (hash of the key for even load, range or time for pruning and tiering). A partition is the unit of placement, replication, movement and recovery. A cluster of N nodes holds many partitions; each node holds a few percent of the data.
  • Hot data: 3 replicas per partition, each partition its own Raft group (5 for the most critical). Writes go to the partition's leader and commit on a majority; leaders are spread over all nodes so every node serves writes (multi-master, option A). Reads can be served by any replica (follower reads with a read index), so read capacity grows with the copies. Copies are placed in different failure domains (rack, availability zone); a lost node's partitions are re-replicated in parallel from many sources, so repair time shrinks as the cluster grows.
  • Warm and cold data: erasure coding instead of copies. Three copies cost 3x the space; a Reed-Solomon scheme such as 8 data + 3 parity pieces costs 1.375x and survives any 3 lost pieces. Old immutable files (the sorted files of the storage engine never change, which is what makes this possible) are encoded when a partition moves to the cold tier. Reads of cold data are slower (gather pieces), which is the accepted price. Hot data stays replicated: erasure coding costs CPU and latency on writes.
  • Search efficiency: the partition key goes in the router's placement table, so a query on it touches one partition; other queries scatter to partitions in parallel and merge (partial aggregation on each partition). Secondary indexes are local to a partition (cheap to maintain, a query without the partition key hits all partitions) with an optional global index for hot lookups. Zone maps and per-file bloom filters let a partition skip files.
  • Rebalancing: adding a node moves whole partitions (consistent placement), splitting a partition that grows past a size limit; both online.
  • Why this order: the storage engine comes first (raftdb-lsm: partitions are made of immutable sorted files, cheap to copy, to erasure-code and to recover), then partitioning with Raft per partition, then tiering and erasure coding.

Redundancy: what the industry does (researched 2026-11-09; the owner asked whether "3 copies" is the best way)#

SystemHot / latency-sensitive dataCold / large dataSource
HDFS3x replication = 200 % overheaderasure coding, typically at most 50 % overhead; costs more network, best for data that is rarely modified; small files fit badlyApache HDFS and Cloudera documentation
Cephdatabases on a replicated pool, size 3 (EC needs k+m writes, so write latency is higher)EC pools for write-once, sequential, large objects; profiles at 1.33-1.5xRook/Ceph guidance
Azure Storage3 full copies while the data is newsealed extents are erasure-coded lazily in the background and the copies deleted: Reed-Solomon 6+3 = 1.5x; Local Reconstruction Codes about 1.29-1.33x with half the repair readsUSENIX ATC 2012 paper, Microsoft Research
Facebook f4Haystack: 3 copies on RAID-6 = 3.6xf4: Reed-Solomon (10,4) = 1.4x inside a data center, plus one XOR'd copy in another data center = 2.1x, tolerating a whole data centerf4 paper (OSDI 2014) and summaries
CockroachDBdefault replication factor 3, 5 when the database must survive the loss of a region; tolerates (RF-1)/2 failures; more replicas slow writes (more must agree)n/a (replication only)CockroachDB documentation

From my own knowledge, not verified in this research: TiKV defaults to 3 Raft replicas per region, Cassandra deployments mostly use RF 3 with quorum reads and writes, Spanner keeps 3 or 5 Paxos replicas per split and offers "witness" replicas that vote but hold no data.

Conclusion for Raft DB: the owner's 3 copies is the industry standard for hot, writable data, and every large system that cares about cost then switches old, immutable data to erasure coding. So: hot = 3 replicas per partition (5 where a site must be survivable plus one more failure), cold = erasure-coded immutable files (Local Reconstruction Code style, about 1.3-1.5x) with a copy in a second site. Two refinements to evaluate: (a) a witness replica (votes in Raft, stores only the log, no data) as the third member of a partition to cut hot-data cost to about 2x when only two sites have room; (b) an HDD-backed erasure-coded cold tier with the partition's hot copies on NVMe. Why not erasure coding for everything: a write must reach k+m nodes and a small read needs several nodes, which is exactly the OLTP path.

Colocation: nodes in different server farms (sites)#

How it works, and what changes:

  • Failure domains. Every node is labelled (region / site / rack). Placement puts the replicas of a partition in different sites; with 3 sites and 3 replicas the cluster survives the loss of a whole site. The cluster layer already elects by majority and fences by term, which is what makes a site loss safe.
  • Latency is the new cost. A write commits when a majority has it, so the cost is the round trip to the nearest site that completes the majority (leader plus the nearest follower), not to the farthest. Leaders are placed (and moved) near the writers; Raft timeouts must be several round trips (election at least 10 x RTT; the current tick of 100 ms and election of 1-2 s suit about 100 ms links). Reads can be served by followers in the local site (read index or bounded staleness), so remote sites do not slow reads. Read-only learner replicas (already in raftdb-raft) give a remote site local reads without taking part in the quorum.
  • Partition by site where required (data residency or latency): the partition key includes the site, replicas stay inside the allowed sites.
  • WAN behaviour: batching and compression of the replication stream, per-peer bounded queues (already so), tolerance of one-way and asymmetric partitions (Raft handles both).
  • Security: the peer messages are authenticated (HMAC) but not encrypted, and the data stream has no TLS; across the internet the nodes must be connected through a tunnel (WireGuard or SSH) until TLS exists. TLS is a blocker for real multi-site use.
  • Test plan (needs the owner's go for the hosted server): three sites = test server A (a Linux test server in a cloud region; the test machines are called A, B and C on this page), test server B (a hosted server at a different provider and location) and a third node that is either test server C (when it is reachable again) or this PC behind SSH tunnels. Measure: the round trip between the sites; write latency with the leader in each site; takeover time when a site is cut off (firewall rule, then kill -9, then reconnect); that no acknowledged write is lost; the read latency of a learner. The hosted server is a live production machine: a Raft DB node would run as one resource-capped unit on loopback with the SSH tunnel (as before), light load only, the failover test would stop only the Raft DB process, and nothing else on it is touched. This needs the owner's explicit OK each time.

6. Install and configuration: a basic single server must not need these many options#

Today a server is started with flags (--dir, --addr, --user, --sync-replicas, --cluster-* and more) and a secure single server needs the operator to know which ones matter. Plan:

  1. A zero-flag first run. raftdb-server with no arguments uses the "single" profile: data in the operating system's standard place (/var/lib/raftdb, %ProgramData%\RaftDB, or ./raftdb-data for a non-privileged user), listens on loopback 127.0.0.1:7480, sizes itself from the machine (shards from the cores, memtable from the RAM), creates an admin account with a random password on the first start and writes it once to a file readable only by its owner (and prints where). No cluster, replication, sync or UDP setting exists in this profile.
  2. Profiles instead of options. single (default), primary (listens on the network, needs TLS or a tunnel, creates a replication account), replica, cluster. A profile sets sensible defaults for everything below it.
  3. One config file raftdb.conf (key = value, comments, parsed by hand, no dependency). Precedence: command line, environment, file, profile defaults. raftdb-server --print-config shows what is in effect, --check-config validates it.
  4. raftdb-server init --profile NAME writes a minimal file containing only the options that profile needs, with a comment on each; it never prompts (installers cannot answer prompts); --interactive is for people.
  5. Service installation. raftdb-server install-service writes the systemd unit (Linux) or registers the Windows service, starts it and prints the connection line; packages (deb, rpm, MSI) call the same command after install. Upgrade from single to cluster: raftdb-server init --profile cluster --join HOST changes the file, nothing else.
  6. The watcher reads the same file so raftdb-watch needs no separate address, credential or restart-command settings for the normal case.

Target: on a fresh machine, one command gives a running, authenticated server with zero flags; a test starts raftdb-server with only --dir and checks it listens on loopback, requires login, and survives a restart without regenerating the password; the number of options in the "single" profile's file is at most five.

Status 2026-11-09: items 1-4 and the target of this section are built (D44); item 5 (install-service, packages) and item 6 (the watcher reading raftdb.conf) are not.

Multi-site test, first result (2026-11-10, variant 1: test server A + test server B + this PC as members)#

Three members in three places (test server A in a cloud region, test server B as one resource-capped service run as an unprivileged user, this PC), every listener on loopback, all traffic through SSH tunnels with the PC as the hub (settings from a raftdb.conf per node; tick 400 ms, so elections take 4-8 s). Measured: client round trip PC to test server A 79 ms, to test server B 87 ms; write through the test server A leader 165 ms median (client round trip plus one follower round trip). kill -9 of the leader process: writes refused 8.3 s, a new leader elected, the follower refused writes, the old leader came back and caught up (14.5 s after the fault). Cutting test server B's tunnel (site cut): the two other sites kept writing 0.5 s after the cut, the isolated node refused writes (error 12), and after reconnecting it caught up in 0.4 s. At the end 105 acknowledged writes, 0 missing on any of the three nodes. Limits: the hub makes test server A to test server B traffic go through the PC (so those two sites' mutual round trip is the sum of both legs, not a direct link); a 3-node run is one sample, not a soak; the leader was on test server A then the PC, never test server B. Not done: the owner then asked for a variant with this PC as client only and the three servers test server C, test server A and test server B. test server C was unreachable after a soft and a hard reset (the cloud console showed it running and its metrics flowed, but SSH and ping from another instance in the same subnet timed out), so that variant was blocked until the instance could be repaired from the inside.

Multi-site test, second result (2026-11-10, variant 2: test server C, test server A and test server B as the three servers; this PC client only)#

Same method as variant 1 (loopback listeners, SSH tunnels with the PC as the hub; tick 400 ms). test server C is now a small instance (1 GB RAM, see below) running the binary copied from test server A. Two full runs, both PASS. Second run: client round trip 76-82 ms to every site; first leader test server B; write through the test server B leader 297 ms median (830 ms worst), through the test server A leader 245 ms median; kill -9 of the test server B leader: writes refused 7.1 s, test server A took over, the follower refused writes, the old leader rejoined and caught up 20.6 s after the fault; cutting the leader site's tunnel (test server A): the other two sites accepted writes again after 26.5 s (the figure includes the client's 8 s attempts, the 4-8 s election timeout and the hub's relay; run 1 showed 20.6 s), the isolated node refused writes (error 12), and caught up 0.2 s after reconnecting. 49 acknowledged writes, 0 missing on any node (run 1: 36 and 0). Limits as before: the hub makes every inter-site message cross this PC, so write latency (245-300 ms) is client-to-hub-to-site twice, not the sites' own round trips; two samples are not a soak. How test server C got here: its own firewall did not allow this PC, so it did not answer SSH. The instance was replaced from a backup, as a small instance (1 GB RAM), and its firewall now allows this PC.

Status 2026-11-10: item 5 of this section (install-service) is built (D45, Linux systemd and a Windows startup task); packages and item 6 (the watcher reading raftdb.conf) are not.

Status 2026-11-10 (section 5, VLDB): the server can keep tables in raftdb-lsm (engine = lsm, D46). Next, in order: (1) replication and failover for lsm tables (a separate replication log or SST shipping plus a log tail), (2) secondary indexes over lsm tables, (3) closing the read gap (restart points, lock-free version pointer, skipping the existed read), (4) partitions with a Raft group each, (5) tiering and erasure coding for cold files.

Status 2026-11-10 (section 5, VLDB): replication, synchronous replicas and failover work for lsm tables (D47). Next, in order: (1) secondary indexes over lsm tables, (2) closing the read gap (restart points, lock-free version pointer, skipping the existed read), (3) partitions with a Raft group each, (4) tiering and erasure coding for cold files, (5) segmenting the replication log so restart does not read all of it.

Status 2026-11-10 (section 5, VLDB): secondary indexes work on lsm tables (D48). Next, in order: (1) closing the read gap (restart points, lock-free version pointer, skipping the existed read), (2) partitions with a Raft group each, (3) tiering and erasure coding for cold files, (4) segmenting the replication log so restart does not read all of it, (5) covering reads and dropping indexes.

Status 2026-11-10 (section 5, VLDB): the lsm read gap is closed to 1.27x of the in-memory engine (D49). Next, in order: (1) partitions with a Raft group each, (2) tiering and erasure coding for cold files, (3) segmenting the replication log so restart does not read all of it, (4) covering reads and dropping indexes, (5) the last of the read gap (lock-free file list, zero-copy get).

Status 2026-11-10 (owner decision D51): before table groups (D50 layer 1) the control plane moves to the watcher: C1 the fence and control interface in the server, C2 the watcher quorum (elections, failover, leases), C3 resource control (OS limits and database throttles), C4 remove the in-server election; then D50 layer 1 on top of it. Backups and copy/rebuild keep using the operator-configured commands of D41 for now.

Status 2026-11-10 (D51): C1 is built (the fence and control interface in the server). Next: C2 (the watcher quorum: elections, failover, leases), C3 (resource control), C4 (remove the in-server election), then D50 layer 1.

Status 2026-11-10 (D51): C2 is built (the watcher quorum: elections, leases, failover, ranking by data epoch); next C3 (resource control), then C4 (remove the in-server election), the test server A kill -9 run of the quorum, then D50 layer 1.

Status 2026-11-10 (D51): the watcher quorum passed its first real-process kill -9 run on test server A. Next: C3 (resource control), C4 (remove the in-server election), then D50 layer 1; repeated and three-machine runs of the C2 test are still to do.

Status 2026-11-10 (D51): C3 (resource control) is built and measured on test server A (a modest gain: tail latency about 2.5x lower, no write loss; small sample). Next: C4 (remove the in-server election), then D50 layer 1 (table groups); repeated and three-machine runs of the C2 test and a harder C3 load are still to do.

Status 2026-11-10 (D51): C4 is done: the election is gone from the server (cluster.rs removed, cluster profile and settings removed); failover is the watcher quorum only. Next: D50 layer 1 (table groups on the watcher control plane); repeated and three-machine runs of the C2 test and a harder C3 load are still to do.

Status 2026-11-10 (D50 layer 1): G1a is built (the server knows table groups: per-group fence, replication and write checks). Next: G1b (forwarding of requests for tables led by another node), G1c (the watcher decides one primary per group), G1d (the test on test server A with three nodes and three groups).

Status 2026-11-10 (D50 layer 1): G1b is built (forwarding of requests for tables led by another node). Next: G1c (the watcher decides one primary per group), G1d (the test on test server A with three nodes and three groups).

Status 2026-11-10 (D50 layer 1): G1c is built (the watcher quorum decides one primary per group, spreads them, fails over per group; passed with three running servers and three watchers). Next: G1d, the test on test server A with three processes and three groups: writes through every node, kill -9 of a node, and the aggregate write rate with the leaders spread against one leader.

Status 2026-11-10 (D50 layer 1): G1d ran on real processes (test server A, full; this PC and test server B, throughput only). Routing, failover per group and no loss of acknowledged writes hold; the throughput part of the test (more writes with the leaders spread) is NOT demonstrated on one machine (0 to 16 % higher) and needs three hosts. Layer 1 is built; open: a three-host throughput run, rebalancing leaders after a node returns, pipelined forwarding (forwarded requests are one at a time per connection). Next layers: 2 (partitioned tables), 3 (true partitioning), 4 (split/merge).

Status 2026-11-10 (D50 layer 2): L2a (create, list, drop, placement over groups), L2b (JSON put/get/delete routed by key) and L2c (queries, indexes, stats over all partitions) are built. L2d (the test on test server A) passed: layer 2 is complete. Import and rename on a partitioned table, planned handover, leader rebalancing and pipelined forwarding are built. Open: a three-host throughput run (needs three comparable machines on one network), layers 3 and 4, log segmenting, covering reads and dropping indexes, TLS between watchers.

7. Hardware acceleration where it pays (owner's idea 2026-11-11)#

Idea. Use the hardware the machine has, where it makes Raft DB faster, and fall back to plain code where it does not.

What exists already. SHA-256 and HMAC use the SHA instructions when the CPU has them (raftdb-proto/src/sha.rs, checked with is_x86_feature_detected!), and CRC-32C for the log uses SSE4.2 (raftdb-wal/src/crc.rs). Both keep the plain implementation as the reference and as the fallback, and both are tested against it. The method below is that method, applied to more places.

Rules (they are the project's standing rules, not new ones). The engine crates stay free of dependencies, so only std::arch is used, with runtime detection (is_x86_feature_detected!, and the aarch64 equivalent), never a build-time assumption: one binary must run on every machine. Every accelerated path has a plain reference implementation in the same crate and a test that compares the two on random and on edge-case inputs. Every unsafe block says why it is sound (the lint is on). MSRV is 1.80, so only what is stable there: SSE4.2, AVX2, PCLMULQDQ, SHA, AES-NI, and NEON on aarch64; AVX-512 is not stable at 1.80 and is out until the MSRV moves. A setting (accel = auto | off) turns it off, and GET /v1/server says which paths are active, so a result can always be reproduced without it. A path is kept only if it is measured faster in the benchmark that matters for it, on a machine that has the feature; if it is not, it is removed.

Candidates, in the order I would measure them (profile first; do not guess):

  1. Scans and filters: comparing and searching bytes over many rows (memchr-like search for a key or a value, equality and range tests on numbers and short strings) with AVX2 / NEON. Probably the biggest gain for queries over large tables, and the partitioned scans of layer 2 multiply it.
  2. Hashing for placement and routing: group_of and partition_of use FNV-1a (a byte at a time); a hardware-friendlier hash (CRC-32C instructions, or a multiply-based 8-byte-at-a-time hash) is faster for long keys. It changes where keys land, so it needs a format version and a migration, and is only worth it if the profile shows the hash.
  3. JSON parsing and encoding: a SIMD pass to find structural characters (the technique of simdjson) for the import and the HTTP paths.
  4. Checksums and copies elsewhere (the LSM engine's blocks, the replication stream): reuse the CRC path.
  5. Encryption at rest, if it is ever added: AES-NI is the reason it would not be slow.
  6. I/O: io_uring and direct I/O on Linux can raise the log and LSM throughput, but they need system calls that std does not wrap, which means raw syscall assembly in an engine crate that has no dependencies; a separate, later decision.
  7. GPUs: not for point reads and writes (the transfer costs more than the work). Maybe, much later, for scans and sorts of very large tables; not planned.

Target for each step: a benchmark before and after on a machine with the feature and on one without (the plain path must not get slower), the reference comparison test, clippy, and the result written into the decision log with the numbers, including when it did not help.

8. One database that speaks MySQL, MariaDB and Microsoft SQL Server (owner's dream 2026-11-11)#

Idea. An application written for MySQL, MariaDB or SQL Server connects to Raft DB with its existing driver and works: Raft DB answers the way that server would, translates what the application sends (queries, tables, keys, stored procedures, triggers, full-text search) into what Raft DB does, and keeps one backend. One database for an existing application.

Is it possible? Yes for a large and useful part; not completely, and not quickly. Plainly:

Where the translation belongs. If it lives in the client connector, the application must change its driver, which defeats "my existing application". It should live in the server, as protocol front-ends: Raft DB listens on a MySQL port (3306) and a SQL Server port (1433) and speaks those wire protocols itself (MySQL's protocol and Microsoft's TDS are documented), so unmodified drivers, ORMs and tools connect. The binary, JSON and HTTP protocols stay as they are. The front-end only translates; the backend is the same.

What is straightforward. The wire protocols (handshake, authentication plugins, text and prepared statements, result sets, error codes and SQLSTATEs in each server's own numbering); the connection-time chatter every driver and ORM sends (SELECT VERSION(), SET NAMES, SELECT @@..., information_schema and sys.* queries); mapping column types to Raft DB's values; INSERT, UPDATE, DELETE, SELECT with WHERE, ORDER BY, LIMIT/TOP, auto-increment and identity columns.

What is missing in Raft DB today, and has to be built in the engine, not in the translator (this is where the real cost is):

  • A relational layer. Raft DB stores JSON documents. A MySQL/SQL Server table has declared columns, types, NOT NULL, defaults, primary and unique keys, foreign keys, collations. Raft DB has some schema constraints (the raftdb-schema crate and the constraint errors of the write path); a full relational table definition on top of documents (kept in the catalog, enforced on write, replicated like any catalog change) has to be designed.
  • More SQL. The SQL of Raft DB today is a subset of SELECT (WHERE, ORDER BY, LIMIT/OFFSET, a column list, COUNT(*)); there is no INSERT/UPDATE/DELETE in SQL (writes go through the JSON and binary APIs), no LIKE, no GROUP BY/HAVING, no joins, no subqueries, no UNION, no window functions, no functions other than COUNT(*). Real applications need all of them, plus each dialect's functions (CONCAT, IFNULL, ISNULL, DATEADD, LIMIT vs TOP vs OFFSET ... FETCH, quoting with backticks vs brackets).
  • Transactions. Applications assume multi-statement transactions with isolation (BEGIN/COMMIT/ROLLBACK, savepoints, SELECT ... FOR UPDATE). The server exposes none: a write is atomic on its own. The building block exists (raftdb-mvcc: InnoDB-style row versions, snapshots and undo, decision D15, measured in the benchmarks) but the server does not use it yet. Wiring it into the write path and the replication log, and a transaction manager (on one group first; across groups and partitions it is a distributed-commit problem, two-phase commit, already listed as refused-until-built in D50), is a large design of its own, and many applications will not work without it.
  • Triggers and stored procedures. These need the engine to call code at a write (triggers) and an interpreter for the procedural language of each server (MySQL's stored-program language, T-SQL: variables, control flow, cursors, error handling). T-SQL alone is a big language. They are translated or interpreted, not "converted to a Raft DB query".
  • Full-text search. MATCH ... AGAINST and CONTAINS/FREETEXT need an inverted index in Raft DB (tokenising, ranking), which Raft DB does not have; its results will be similar, not identical, to each server's.
  • Dialect details that applications do depend on: case sensitivity and collation, date/time and decimal arithmetic, implicit conversions, the exact text of error messages, AUTO_INCREMENT and IDENTITY behaviour after rollbacks, GROUP BY rules, locking behaviour.

What I would promise, and what not. Not "any MySQL or SQL Server application will run". A plan that can be checked: pick real targets (for example a popular PHP application and the test suite of an ORM such as SQLAlchemy or Hibernate for each dialect), and make those pass, level by level. Compatibility is measured by those suites, not claimed. Where Raft DB cannot do something it answers with the server's own "not supported" error, never with a silently different result.

Levels (each a step with a target, in this order):

  1. Wire protocol and the basics. MySQL protocol on its own port; connect with the standard mysql client and one driver, run CREATE TABLE/INSERT/SELECT/UPDATE/DELETE on simple tables, prepared statements, the driver start-up queries. Target: the client and two drivers connect and a CRUD script gives the same output as MySQL (checked against a real MySQL on a test host).
  2. The relational layer and DDL. Declared columns and types, keys, NOT NULL, defaults, auto-increment, secondary indexes, ALTER TABLE for the common cases, information_schema. Target: an ORM creates its schema through Raft DB and reads it back.
  3. The SQL of applications. Joins, GROUP BY/HAVING, aggregates, subqueries, UNION, the common functions, in the shared executor so that the JSON API gets them too. Target: a published SQL conformance subset and the ORM's query tests.
  4. Transactions. Single-group transactions with snapshot isolation first; FOR UPDATE; then the question of transactions across groups and partitions (the distributed-commit design is a decision to take with the owner, because it costs latency and complexity).
  5. The same for TDS (SQL Server) and its dialect, and the MariaDB differences (they are small next to MySQL).
  6. Triggers, then stored procedures and functions, then full-text search. Each is an engine feature first (hooks at write time; an interpreter; an inverted index) and a translation second. Level 1 alone is a few weeks of work; levels 2 to 4 are months and change the engine's core; level 6 is the long tail. The first two levels already make Raft DB usable for simple applications and tools, and give a real measurement of how far a given application can go before deciding on the rest.

Decided 2026-11-11 (owner): MySQL first; the work lives in a connector, only missing features go into the core; SQL Server follows as a sibling crate (decision D52). Levels 1a (protocol, sessions, databases), 1b (tables and rows) and 1c (prepared statements), all checked against a real MySQL 9.7 (the mysql client and Connector/J), are built, and so are the unique keys of level 2a (no core change was needed); next in level 2 are information_schema and ALTER TABLE and level 3 (joins, GROUP BY, the rest of SQL in the shared executor).

Questions for the owner before level 1: which applications or frameworks matter most (that decides the order inside levels 2 and 3); whether MySQL or SQL Server comes first; whether strict compatibility or "works for my application" is the target; and whether trademarks matter for the wording ("speaks the MySQL protocol" is accurate; "is MySQL" is not).

Added by the owner 2026-11-11, in this order after what is built (2a unique keys, 2b information_schema):

  1. Accounts and privileges that match MySQL (level 2d): CREATE USER ... IDENTIFIED BY, ALTER USER, DROP USER, RENAME USER, GRANT/REVOKE at global, database, table and column level with MySQL's privilege names, SHOW GRANTS, SET PASSWORD, roles later, the mysql.user/mysql.db views and the privilege checks on every statement with MySQL's errors (1044, 1142, 1143, 1045). Today the MySQL users are lines of the connector's configuration; they become the bootstrap administrators, and every other account lives in Raft DB (a hidden database) with the two password verifiers (SHA1(SHA1(pw)) and SHA256(SHA256(pw)), never the password), so that both password plugins keep working.
  2. Popular applications as the acceptance test (the owner: SQL of WordPress, PrestaShop and similar must work with Raft DB "from install to using all the functions"): each application is installed through its own installer against the connector and used (log in, create and edit content, search, plugins, upgrade); the SQL it sends is captured with RAFTDB_MYSQL_TRACE and every statement that is refused becomes a work item, ordered by how many applications need it. What is known to be needed already: joins, GROUP BY/HAVING/DISTINCT, subqueries, UNION, INSERT ... SELECT, ALTER TABLE, SHOW TABLE STATUS/SHOW FULL COLUMNS, prefix indexes (KEY slug (slug(191)), parsed, indexed on the whole column), FOUND_ROWS()/SQL_CALC_FOUND_ROWS, GROUP_CONCAT, START TRANSACTION/COMMIT/ROLLBACK with real isolation (level 4: the raftdb-mvcc crate exists), FULLTEXT indexes (a core feature: an inverted index), LOCK TABLES/SELECT ... FOR UPDATE, utf8mb4 collation details, information_schema joins. Needs from the owner when we get there: PHP (CLI with mysqli/pdo_mysql) and the application packages (WordPress is about 25 MB, PrestaShop about 70 MB; a download needs the owner's OK), and a place to run them (this PC, or test server A with php -S). Hard constraint (owner, 2026-11-11): nothing changes on the application side and nothing in its driver. The application and its stock MySQL driver (PHP mysqli/pdo_mysql, JDBC, Python, Node, .NET, ...) are used exactly as they are; the only change is the connection string, the MySQL way (host, port, user, password, database). So the connector must behave as a MySQL server to whatever the unmodified driver does by default: listen on 3306 in a normal deployment (3307 is only this PC's test port, because it has a MySQL of its own), accept both password plugins, handle a client that offers TLS (today it is answered as "no TLS", which every driver's default mode accepts; a client that requires TLS needs TLS support in the connector, a later step), send the capabilities and metadata the drivers expect, and never need a setting, a patch or a plugin on the application's side. Anything an application needs that the connector lacks is built in the connector or the core, never worked around in the application.
  3. Fatal-error reporting to us (see D53): the servers and the connector report fatal errors in database functionality to a server the owner names.