From 5ee45fd34d50acd41af63907b35dd6eefb3f7683 Mon Sep 17 00:00:00 2001 From: Aditya Mukhopadhyay Date: Wed, 2 Dec 2026 21:36:09 +0530 Subject: [PATCH] Clarify configuration and large transaction recovery --- docs/CONFIGURATION.md | 17 ++++++++--------- docs/DURABILITY.md | 6 +++--- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index 63d443482e..5065c0c2ea 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -1,19 +1,18 @@ # Configuration -Minigraf needs no configuration: `Minigraf::open("app.graph")` uses safe -defaults. `OpenOptions` changes them for one handle. Nothing here is stored -in the `.graph` file; each open sets it. +`Minigraf::open("app.graph")` opens a database with the default settings. +Use `OpenOptions` to change settings for the handle you open. Minigraf does +not save these settings in the `.graph` file. -This page lists every `OpenOptions` setting, where else it can be changed, -and how the embedder controls which settings query text may override -(`allow_overrides`, #862). +The table lists each `OpenOptions` setting, its default, and where you can +change it. ## Settings and where they can be changed "Query text" means keywords in the query vector, such as -`:max-derived-facts 1000`. Query text is gated by -[`allow_overrides`](#allow_overrides). Settings changed from application -code are not gated. +`:max-derived-facts 1000`. Use [`allow_overrides`](#allow_overrides) to choose which settings queries +can change with keywords (#862). It does not restrict changes made in +application code. | `OpenOptions` field | Default | Also changed by | Semantics of an override | |---|---|---|---| diff --git a/docs/DURABILITY.md b/docs/DURABILITY.md index efc90cf09d..f227a3a7c3 100644 --- a/docs/DURABILITY.md +++ b/docs/DURABILITY.md @@ -56,11 +56,11 @@ For example, a database opened `Full` can run a bulk load as `Normal` transactio ### Large transactions -On a file-backed database, a transaction becomes **large** when its staged facts would exceed `transaction_chunk_facts` (default 65,536, or the `TxOptions::chunk_facts` override for a `WriteTransaction`). It writes chunks into copy-on-write working trees in `app.graph`. Earlier committed facts still pending in memory join those trees first. Commit syncs the pages, writes the next meta page, syncs again, then deletes the WAL. It writes no WAL entry for the large transaction and is durable in either sync mode, regardless of `wal_checkpoint_threshold`. +On a file-backed database, a transaction becomes **large** when its staged facts would exceed `transaction_chunk_facts` (default 65,536, or the `TxOptions::chunk_facts` override for a `WriteTransaction`). It builds new trees by copying pages as needed in `app.graph`. It writes any committed facts still pending in memory into those trees first, then writes the large transaction's facts in chunks. Commit syncs the pages, writes the next meta page, syncs again, then deletes the WAL. It writes no WAL entry for the large transaction and is durable in either sync mode, regardless of `wal_checkpoint_threshold`. -Before the first working page write, the transaction ensures a WAL exists as a recovery guard. If it creates the WAL, it writes and syncs the header and syncs the parent directory, even in `Normal` mode; an existing WAL retains its earlier entries. +Before writing the first page, the transaction makes sure a WAL exists. If a crash interrupts the transaction before commit, the WAL header identifies the base generation to reopen; it does not contain the large transaction's writes. If it creates the WAL, it writes and syncs the header and syncs the parent directory, even in `Normal` mode; an existing WAL retains its earlier entries. -A large `WriteTransaction` rolled back or dropped without `commit()` may therefore have created that WAL and written index and dictionary pages, long-value pages, and temporary claims-tree pages used to track triples replaced by a statement. These writes may include copies of earlier committed, uncheckpointed facts as well as the transaction's own facts. Rollback publishes no meta page and leaves the committed state unchanged: the written pages are free in the active generation or beyond its page count. It does not erase those bytes or delete the WAL guard. The handle is marked dirty so the next checkpoint writes a meta page before removing the WAL. A crash before the large transaction's commit point likewise leaves its facts uncommitted; only earlier transactions in the WAL are replayed. +A large `WriteTransaction` rolled back or dropped without `commit()` may therefore have created that WAL and written index and dictionary pages, long-value pages, and temporary claims-tree pages used to track triples replaced by a statement. These writes may include copies of earlier committed, uncheckpointed facts as well as the transaction's own facts. Rollback publishes no meta page and leaves the committed state unchanged: the written pages are free in the active generation or beyond its page count. It does not erase those bytes or delete the WAL. The handle is marked dirty so the next checkpoint writes a meta page before removing the WAL. A crash before the large transaction's commit point likewise leaves its facts uncommitted; only earlier transactions in the WAL are replayed. **What durability assumes.** A sync is only as good as the storage under it. Minigraf assumes that when `fdatasync`/`fsync` (`FlushFileBuffers` on Windows) returns, the data is on stable storage. Disks or controllers with a volatile write cache that ignore flushes, virtual machines with an "unsafe" disk cache mode, and some network or FUSE filesystems break that assumption, and a power loss there can lose committed transactions or tear a page. A torn or rotted page is detected by its checksum on the next read (`STG-029`); it is not silently read.