Skip to content

Checkpoints: a copy of the store that opens as it was, at /_checkpoint - #48

Merged
mumtaz6 merged 2 commits into
masterfrom
checkpoints
Oct 4, 2026
Merged

mumtaz6 merged 2 commits into
masterfrom
checkpoints

Conversation

@mumtaz6

@mumtaz6 mumtaz6 commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #47 (metrics). Ported from unitdb_internal (its commits cb89818 and d334636).

Why: a copy of a running store's files isn't a backup. The files are copied at different moments, and the WAL isn't fsynced, so a volume snapshot is like a power cut.

Checkpoint (adapter):

  • It holds writes back until the DB has written out the latest, about 1.1 s with the defaults.
  • It syncs the DB and copies its files, then copies memdb's records (not its files) into a fresh memdb. Reads go on.
  • The copy opens with db_path set to it, as after a clean shutdown, and only with the same keyring.

POST /_checkpoint on the monitor port, with Authorization: Bearer <CHECKPOINT_TOKEN>, writes one into CHECKPOINT_DIR/ckpt-<UTC time>:

  • Off unless both settings are set.
  • One at a time, one per CHECKPOINT_MIN_MINUTES (10).
  • The newest CHECKPOINT_KEEP (3) are kept.

Restoring is starting a server with -db_path at the checkpoint and the same keyring.

Metrics: /_metrics reports the store's size, and the checkpoints' last success, failures and duration.

Tests: the adapter's TestCheckpoint (writes going on during the checkpoint), TestCheckpointAndStats, and the e2e restore drill TestBackupCheckpointRestores.

🤖 Generated with Claude Code

A copy of a running store's files is not a backup: they are copied at
different moments, and the WAL isn't fsynced, so a volume snapshot is
like a power cut. The adapter's Checkpoint copies the store between
writes instead: it holds writes back until the DB has written out the
latest (about 1.1 s with the defaults), syncs it and copies its files,
and copies memdb's records, not its files, into a fresh memdb. Reads go
on. The copy opens with db_path set to it, as after a clean shutdown,
and with the same keyring only.

Stats reports the store's messages, disk bytes and memdb records.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
POST /_checkpoint on the monitor port, with "Authorization: Bearer
<CHECKPOINT_TOKEN>", writes a checkpoint of the store into
CHECKPOINT_DIR/ckpt-<UTC time>, for a volume snapshot or a copy
elsewhere; restoring is starting a server with -db_path at it and the
same keyring. Off unless CHECKPOINT_DIR and CHECKPOINT_TOKEN are both
set; one at a time, one per CHECKPOINT_MIN_MINUTES (10); the newest
CHECKPOINT_KEEP (3) are kept.

/_metrics reports the store's size, and the checkpoints' last success,
failures and duration.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mumtaz6
mumtaz6 changed the base branch from metrics to master October 4, 2026 16:04
@mumtaz6
mumtaz6 merged commit c0b0616 into master Oct 4, 2026
6 checks passed
@mumtaz6
mumtaz6 deleted the checkpoints branch October 6, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant