Getting started

Where data lives

The data directory of a server, what each file and folder in it is, and where the SQL front-end keeps its own definitions.

The data directory#

The server's dir (see raftdb-server settings) holds everything. If you give none, the server uses /var/lib/raftdb or %ProgramData%\RaftDB when that folder exists (an installer or install-service creates it), otherwise ./raftdb-data relative to the working directory. Start the server from the same working directory every time if you rely on the last case.

<dir>/
  admin.password            generated admin password (first start; owner-readable only)
  replicator.password       primary profile only: the read-only replication account
  control.state             managed node: epoch, lease role, dirty flag, data epoch (per group)
  reports/                  fatal-error reports (newest 50 kept); reports/pending/ holds unsent ones
  <database>/               one directory per database
    <table>/                one directory per table
      shard-0.log ...       memory engine: the write-ahead log of each shard
      lsm-0/ ...            lsm engine: sorted files, manifest, log segments of each shard
      repl-0.log ...        lsm engine on a replicating server: the replication log

A database is a directory and a table is a directory of shard logs with its own field-name registry, indexes and shard threads. The server starts with the database main and its table documents; a log in the older layout <dir>/shard-N.log is moved there at start. A partitioned table is several physical tables named T~p0, T~p1, ...

Names in the directory are the names of the native API: 1 to 64 characters of letters, digits, _ and -. The SQL front-end stores a database or table name that Raft DB cannot name encoded (_u_ followed by the bytes, D86), so a MySQL table called my table is a directory with an encoded name.

What the files are#

FileContent
shard-N.logRecords of [len u32][crc u32][payload], 8 bytes overhead per record, CRC-32C over length and payload, zero-filled ahead of the write position. The log is the table: rows, deletes, field names, schema and index definitions are all records. A torn last record is cut at start.
lsm-N/wal-NNNNNNNN.log, NNNNNNNN.sst, MANIFESTLog segment per memtable; sorted files with CRC-protected blocks, an index block and a bloom filter; the live files per level, replaced atomically.
control.stateThe fence: highest epoch seen, role, lease, dirty flag and data epoch per group. Do not edit it.

All integers on disk are explicit little-endian, so the files are the same on every platform.

What the SQL front-end stores#

The front-end keeps its own definitions as ordinary Raft DB tables with hidden names. They are not listed by SHOW TABLES or SHOW DATABASES, but they are there on disk and in backups.

NameWhereContent
__rdb_mysql (or __rdb_mariadb)each databaseDefinitions of the database's tables (columns, types, keys, checks, generated columns) as documents. Its presence marks the database as this front-end's.
__rdb_views, __rdb_routines, __rdb_triggerseach database that has themDefinitions of views, procedures and functions, triggers.
__u_<table>_<index>each databaseThe claim table of one unique index.
__tmp<id>_<name>each databaseA session's temporary table; dropped when the session ends.
__rdb_accounts / accountsa hidden databaseMySQL accounts made by CREATE USER, with the two double password hashes and the grants.

Never write to these tables by hand through the native API.

Moving or copying a data directory#

Stop the server first, then copy the whole directory (see Backup and recovery). A copy made while the server runs is not guaranteed to be consistent.

See also#