NEW RasterizedDB 1.1.0 is out: sharding and the gateway, the message broker, roles and row-level security, compression, .NET on NuGet, and the enterprise edition. What's new ›
DURABILITY

Tested by pulling the plug, in software.

Every commit is written ahead to a log, synced before it is acknowledged by default, and replayed whole or not at all after a crash. A power-loss harness checks that by building the disk images a power cut could leave and opening each one.

HOW IT WORKS · ANIMATED 12 s cycle

An INSERT, from statement to visible row

Every write is logged before it is applied, lands in a reclaimed extent when one fits, and teaches the filter index about itself before it commits.

1 · STATEMENT INSERT INTO users VALUES (8812, 'Oslo', 34); pgwire · MySQL · TDS · rastcp all reach the same executor 2 · WRITE-AHEAD LOG lsn 9180 · tx 55 commit lsn 9181 · tx 56 insert lsn 9182 · tx 56 commit lsn 9183 · tx 57 insert fsync ✓ 3 · ROWS FILE free 48 B 8812 best fit from the free list, else append 4 · POINTER · 37 B id 8812 length 41 pos 0x3F20 deleted 0 xmin 57 xmax — 5 · FILTER INDEX city plane bits, row 8812 zone bounds, age 19 … 33 19 … 34 ✓ COMMIT tx 57 · visible to every snapshot taken from now on
  1. 1
    The statement arrives

    Over any protocol. It is parsed once; a repeated shape is learned and skips the parse next time.

  2. 2
    Written ahead

    A WAL record is appended and synced before the commit is acknowledged; synchronous_commit decides whether the commit waits for that sync.

  3. 3
    Row bytes placed

    The free list offers the best-fitting reclaimed extent. Only when none fits does the rows file grow.

  4. 4
    Pointer record

    37 bytes: id, length, position, deleted, xmin = this transaction, xmax = none.

  5. 5
    Filter index taught

    Each column's fingerprint bits are set for the new row, and its zone's min/max bounds widen.

  6. 6
    Commit

    The transaction is marked committed. Snapshots taken from now on see the row; older ones never will.

1 / 4

synchronous_commit, with the trade stated

On (the default), nothing is acknowledged until its records are durable: one fdatasync per writing statement. Off, a commit returns once its bytes are in the kernel's page cache. A process crash then loses nothing, and only an operating-system crash or power loss costs the last --wal-writer-delay-ms of transactions: whole transactions off the end of the log, never half of one.

shell
rasterizeddb_core --location <PATH> --synchronous-commit off --wal-writer-delay-ms 200
# or live:  SET CONFIG wal.synchronous_commit = off;
2 / 4

Why SIGKILL tests are not enough

A killed process leaves the page cache behind, so it can never lose an unsynced write, keep a later write while losing an earlier one, or undo a rename. A power cut can do all three. So the harness watches every sync and directory operation, and at each cut point freezes what a power loss there could leave:

  • each file as of its last completed sync; a sync still in flight makes nothing durable
  • unsynced 4 KiB pages kept or dropped, page by page, so logs get torn tails
  • directory operations not yet covered by a directory sync kept or reverted, newest first
  • several seeded images per cut, each opened as a fresh database and checked
3 / 4

Damage in the middle of the log stops the start

Since 1.1.0: a torn tail, the normal shape of a crash, is replayed up to the last whole record without a word. Damage followed by valid records is something else, and the server refuses to start rather than quietly drop every commit after it. An operator can choose to replay the prefix and drop the rest, for one start only.

A gap of zeros is told apart from damage: a power cut can keep a later page and drop an earlier one, and that is a crash, not corruption.

shell
rasterizeddb_core --location /var/lib/rasterizeddb --wal-truncate-damaged
# embedded: Builder::open("./data").wal_truncate_damaged(true)
4 / 4

And the rest

  • Replay stops at the first record it cannot read whole
  • Checkpoints bound replay time; the log is preallocated
  • Backups verify log coverage on both sides before a snapshot is recorded
  • Replication logs are written ahead through the same WAL
  • An optional build adds checksums on the read path
✓ page rendered in 180 µs axum + tera + htmx · no other javascript