8000 Clarify configuration and large transaction recovery by adityamukho · Pull Request #977 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
@@ -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 |
|---|---|---|---|
Expand Down
6 changes: 3 additions & 3 deletions docs/DURABILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Loading
0