> Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software.
chunkscope demo · Quillstore docs (fictional)
Chunk size distribution
Retrieval
Query: How do I recover a node after a disk failure?
| Rank | Score | Chunk | Text |
|---|---|---|---|
| 1 | 12.53 | 05 · Operations Runbook #2 heading-aware · 120 words | The peer stops and logs `I/O error` or `CorruptBlock` with a file path. `quill status` on another peer shows it as unreachable, and the gro… |
| 2 | 11.48 | 05 · Operations Runbook #3 heading-aware · 120 words | 1. Confirm that the remaining peers still form a quorum: `quill status --peer 10.0.0.12:7400`. 2. Check the kernel log of the failed machin… |
| 3 | 11.21 | 04 · Replication #8 heading-aware · 120 words | | Failure | Detected by | Automatic response | Operator action | |---|---|---|---| | Disk failure | `CorruptBlock` or I/O errors | Peer sto… |
| 4 | 10.54 | 05 · Operations Runbook #5 heading-aware · 120 words | > **Warning:** commands in this runbook change data on disk. Run them on one peer at a time, and only after taking a backup or confirming t… |
| 5 | 6.329 | 05 · Operations Runbook #4 heading-aware · 120 words | If only a few segments are damaged and the disk is healthy, restore those segments from a peer: ```bash quill restore-segment --from 10.0.0… |
| 6 | 5.736 | 01 · Quillstore Overview #8 heading-aware · 120 words | Quillstore is not a relational database. It has no query planner, no joins and no secondary indexes beyond what you build yourself with add… |
| 7 | 5.225 | 01 · Quillstore Overview #6 heading-aware · 120 words | A Quillstore node has four layers. The table below lists them from the application down to the disk. |
| 8 | 4.89 | 04 · Replication #7 heading-aware · 120 words | | Failure | Detected by | Automatic response | Operator action | |---|---|---|---| | Follower crash | Missing heartbeat replies | Leader ke… |
| 9 | 4.684 | 04 · Replication #10 heading-aware · 120 words | The leader tracks how far behind each follower is, in WAL entries and in bytes. `quill status` shows the lag for each peer. A lag that keep… |
| 10 | 4.053 | 03 · Storage Engine #4 heading-aware · 120 words | A read checks the active memtable, then the frozen memtables, then the segments from newest to oldest. It stops at the first version it fin… |
59 more scored chunk(s). Colour by "Retrieval score" to see them all in context.
Runs
| Run | Chunks | Median words | Max | Over limit | Lowest coverage | Errors | Warnings |
|---|---|---|---|---|---|---|---|
| heading-aware · 120 words | 69 | 53 | 120 | 0 | 0.0% | 13 | |
| fixed-size · 780 chars, 130 overlap | 42 | 125 | 150 | 27 | 100.0% | 27 | 60 |
| blank-line blocks | 171 | 17 | 156 | 3 | 100.0% | 4 | 132 |
Documents
| Document | Chunks | Placed | Median words | Max | Coverage | Errors | Warnings |
|---|---|---|---|---|---|---|---|
| 01 · Quillstore Overview heading-aware · 120 words | 12 | 11 | 44.5 | 120 | 94.4% | 3 | |
| 02 · Installation and Configuration heading-aware · 120 words | 11 | 11 | 57 | 113 | 95.4% | 2 | |
| 03 · Storage Engine heading-aware · 120 words | 13 | 13 | 63 | 118 | 95.7% | 1 | |
| 04 · Replication heading-aware · 120 words | 11 | 11 | 59 | 110 | 95.8% | 2 | |
| 05 · Operations Runbook heading-aware · 120 words | 12 | 12 | 52 | 116 | 94.7% | 1 | |
| 06 · HTTP API Reference heading-aware · 120 words | 9 | 9 | 43 | 118 | 95.4% | 2 | |
| 07 · Release Notes heading-aware · 120 words | 0 | 0 | – | – | 0.0% | 2 | |
| (chunks without a matching source) heading-aware · 120 words | 1 | 0 | 10 | 10 | – | ||
| 01 · Quillstore Overview fixed-size · 780 chars, 130 overlap | 6 | 6 | 128 | 140 | 100.0% | 5 | 9 |
| 02 · Installation and Configuration fixed-size · 780 chars, 130 overlap | 7 | 7 | 119 | 138 | 100.0% | 3 | 12 |
| 03 · Storage Engine fixed-size · 780 chars, 130 overlap | 9 | 9 | 129 | 148 | 100.0% | 7 | 15 |
| 04 · Replication fixed-size · 780 chars, 130 overlap | 6 | 6 | 131 | 144 | 100.0% | 5 | 6 |
| 05 · Operations Runbook fixed-size · 780 chars, 130 overlap | 7 | 7 | 126 | 133 | 100.0% | 5 | 9 |
| 06 · HTTP API Reference fixed-size · 780 chars, 130 overlap | 5 | 5 | 114 | 150 | 100.0% | 1 | 8 |
| 07 · Release Notes fixed-size · 780 chars, 130 overlap | 2 | 2 | 73 | 125 | 100.0% | 1 | 1 |
| 01 · Quillstore Overview blank-line blocks | 24 | 23 | 18 | 132 | 100.0% | 2 | 20 |
| 02 · Installation and Configuration blank-line blocks | 29 | 29 | 11 | 120 | 100.0% | 25 | |
| 03 · Storage Engine blank-line blocks | 35 | 35 | 21 | 67 | 100.0% | 24 | |
| 04 · Replication blank-line blocks | 23 | 23 | 16 | 156 | 100.0% | 1 | 16 |
| 05 · Operations Runbook blank-line blocks | 33 | 33 | 16 | 116 | 100.0% | 23 | |
| 06 · HTTP API Reference blank-line blocks | 19 | 19 | 12 | 130 | 100.0% | 1 | 16 |
| 07 · Release Notes blank-line blocks | 8 | 8 | 10.5 | 48 | 100.0% | 8 |
Issues by type
| Severity | Check | Count | Example |
|---|---|---|---|
| ✕ error | over_limit | 30 | 123 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | empty | 1 | Empty chunk: it has no text to embed. |
| ▲ warning | under_limit | 63 | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | heading_only | 61 | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | starts_mid_word | 27 | Starts in the middle of a word. |
| ▲ warning | ends_mid_word | 20 | Ends in the middle of a word. |
| ▲ warning | split_code_block | 15 | Cuts a code block: the opening or closing ``` fence is in another chunk. |
| ▲ warning | ends_in_table | 8 | Ends inside a table: the table continues in the next chunk. |
| ▲ warning | gaps | 7 | 172 non-whitespace characters in 9 place(s) are not in any chunk, so they cannot be retrieved. This is expected only if your chunker deliberately drops text (headings kept as metadata, boilerplate). |
| ▲ warning | unmatched | 1 | Not found in the source text, so it cannot be placed. |
| ▲ warning | no_chunks | 1 | This document produced no chunks: none of its text will be retrievable. |
| ▲ warning | offset_mismatch | 1 | The chunk's own offsets do not match the source; it was located by search instead. |
| ▲ warning | starts_in_table | 1 | Starts inside a table: these rows are separated from the table header. |
| ℹ info | ends_mid_sentence | 7 | Ends in the middle of a sentence. |
| ℹ info | partial | 4 | Only 78% of the text was found in the source: the chunker transformed it (added headers or context, cleaned markup) or the source differs. |
| ℹ info | no_source | 1 | These chunks are listed but not placed: they could not be matched to a source document. Pass source= or sources= to see them in context. |
| ℹ info | duplicate | 1 | Same text as chunk #3: it will be embedded and retrieved twice. |
01 · Quillstore Overview heading-aware · 120 words
1 chunk(s) could not be placed in the source: #11.
Quillstore is an embedded, persistent key-value store for services that need fast local reads and durable writes without running a separate database server. It links into your application as a library, stores data in a single directory, and can optionally replicate that directory to two or more peers. Quillstore is designed for three workloads: session and cache data that must survive restarts, event logs that are written once and read in order, and configuration snapshots that change rarely but must be identical on every node.
A keyspace is a named collection of keys with its own settings. Each keyspace chooses a compaction strategy, a compression codec and a retention policy. Keys are byte strings of up to 4 KiB; values can be up to 64 MiB, although values above 1 MiB are stored out of line in blob files.
Every write creates a new version of a record. A version carries a 64-bit sequence number assigned by the writer, a timestamp, and an optional time-to-live. Readers see the latest version unless they open a snapshot, which pins the sequence number at the moment it was created.
Before a write is acknowledged, it is appended to the write-ahead log (WAL) and, depending on the durability level, flushed to disk. The WAL is the only structure that must be written synchronously; everything else is rebuilt from it after a crash.
Data on disk lives in immutable segment files. A segment holds sorted keys, a sparse index and a Bloom filter. Segments are merged in the background by compaction, which discards overwritten and expired versions.
A Quillstore node has four layers. The table below lists them from the application down to the disk.
| Layer | Responsibility | Main settings | |---|---|---| | API | Get, put, delete, scan, transactions | `max_batch_bytes`, `read_timeout` | | Memtable | In-memory sorted buffer for recent writes | `memtable_size`, `memtable_count` | | Storage engine | WAL, segments, compaction, blob files | `durability`, `compaction`, `codec` | | Replication | Log shipping to peers, leader election | `peers`, `quorum`, `election_timeout` | Each layer can be tuned independently, but the defaults are chosen to work well together for small and medium datasets of up to a few hundred gigabytes per node.
Quillstore is not a relational database. It has no query planner, no joins and no secondary indexes beyond what you build yourself with additional keyspaces. It is also not designed for datasets that do not fit on one machine: replication copies the whole dataset to every peer instead of sharding it. If you need ad-hoc queries across many fields, or a dataset that grows beyond a single node's disk, use a dedicated database server instead.
- ▲ warning Ends inside a table: the table continues in the next chunk.
| Term | Meaning | |---|---| | Blob file | A file holding large values outside the segments | | Compaction | Background merging of segments to reclaim space | | Durability level | How far a write must travel before it is acknowledged | | Leader | The peer that accepts writes in a replicated group | | Memtable | The in-memory buffer of recent writes | | Quorum | The number of peers that must confirm a replicated write | | Segment | An immutable sorted file of keys and values | | Snapshot | A consistent read view pinned to one sequence number | | Tombstone | A marker that records the deletion of a key |
- ℹ info Only 78% of the text was found in the source: the chunker transformed it (added headers or context, cleaned markup) or the source differs.
| Term | Meaning | |---|---| | WAL | Write-ahead log, the append-only record of every write |
- ▲ warning Not found in the source text, so it cannot be placed.
Summary: Quillstore keeps data in immutable segments and copies them to every peer for safety.
| Severity | Where | Check | Message |
|---|---|---|---|
| ▲ warning | document | gaps | 172 non-whitespace characters in 9 place(s) are not in any chunk, so they cannot be retrieved. This is expected only if your chunker deliberately drops text (headings kept as metadata, boilerplate). |
| ▲ warning | #9 | ends_in_table | Ends inside a table: the table continues in the next chunk. |
| ▲ warning | #11 | unmatched | Not found in the source text, so it cannot be placed. |
| ℹ info | #10 | partial | Only 78% of the text was found in the source: the chunker transformed it (added headers or context, cleaned markup) or the source differs. |
The same document in every run, on the same scale. Click a bar to open that chunk.
02 · Installation and Configuration heading-aware · 120 words
> Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software.
Quillstore runs on 64-bit Linux and macOS. It needs a filesystem that supports `fsync` on directories, which rules out some network filesystems. For production, use a local SSD and reserve at least twice the size of your dataset, because compaction temporarily needs room for both the old and the new segments.
The library is published for Python, Go and Rust. Pick the package for your language: ```bash pip install quillstore # Python 3.10 or newer go get example.org/quillstore/v2 # Go 1.22 or newer cargo add quillstore # Rust 2021 edition ``` The command-line tool, `quill`, is installed with the Python package. It is used for inspection, backups and recovery and never needs to run while your application is running.
A store is opened on a directory. If the directory is empty, Quillstore creates the files it needs.
```python
import quillstore
store = quillstore.open(
"/var/lib/myapp/store",
durability="fsync",
memtable_size="64MiB",
)
with store.transaction() as tx:
tx.put(b"user:42", b'{"name": "Ada"}')
tx.put(b"user:43", b'{"name": "Grace"}')
print(store.get(b"user:42"))
store.close()
```
Always close the store before the process exits. Closing flushes the memtable and writes a clean-shutdown marker, which makes the next start faster because the WAL does not need to be replayed.Instead of passing options in code, you can keep them in a `quillstore.toml` file next to the data directory. Options passed in code override the file. ```toml [store] durability = "fsync" memtable_size = "64MiB" memtable_count = 2 [keyspace.sessions] compaction = "tiered" codec = "lz4" ttl = "24h" [keyspace.events] compaction = "leveled" codec = "zstd" retention = "30d" ```
The table below lists every store-level option, its default and when to change it.
- ▲ warning Ends inside a table: the table continues in the next chunk.
| Option | Default | Description | |---|---|---| | `durability` | `fsync` | `none`, `flush` or `fsync`; see the storage engine guide | | `memtable_size` | `32MiB` | Size at which a memtable is frozen and written to a segment | | `memtable_count` | `2` | Number of memtables kept in memory, including frozen ones | | `max_batch_bytes` | `4MiB` | Largest batch a single transaction may write | | `read_timeout` | `2s` | Time a read waits for a lock before failing | | `compaction_threads` | `2` | Background threads used for compaction | | `blob_threshold` | `1MiB` | Values above this size are stored in blob files |
- ℹ info Only 94% of the text was found in the source: the chunker transformed it (added headers or context, cleaned markup) or the source differs.
| Option | Default | Description | |---|---|---| | `codec` | `lz4` | Default compression: `none`, `lz4` or `zstd` | | `bloom_bits_per_key` | `10` | Bloom filter size; higher means fewer false positives | | `cache_size` | `256MiB` | Block cache shared by all keyspaces | | `max_open_files` | `1000` | Segment files kept open at the same time | | `checksum` | `crc32c` | Checksum used for WAL entries and segment blocks | | `peers` | empty | Addresses of replication peers | | `quorum` | `majority` | Peers that must confirm a replicated write | | `election_timeout` | `1500ms` | Time without a heartbeat before peers elect a new leader |
Most applications only change `durability`, `memtable_size` and `cache_size`. The others exist for unusual workloads and are safe to leave at their defaults.
Two environment variables are read at startup. `QUILL_LOG` sets the log level (`error`, `warn`, `info` or `debug`), and `QUILL_CONFIG` points to a configuration file in a different location. Environment variables never override options passed in code.
Quillstore reads data written by the previous two minor versions. To upgrade across more versions, upgrade one step at a time and open the store once at each step, which converts the segment format. Never downgrade a store that has been opened by a newer version: older versions refuse to open it, to prevent silent data loss.
| Severity | Where | Check | Message |
|---|---|---|---|
| ▲ warning | document | gaps | 156 non-whitespace characters in 8 place(s) are not in any chunk, so they cannot be retrieved. This is expected only if your chunker deliberately drops text (headings kept as metadata, boilerplate). |
| ▲ warning | #6 | ends_in_table | Ends inside a table: the table continues in the next chunk. |
| ℹ info | #7 | partial | Only 94% of the text was found in the source: the chunker transformed it (added headers or context, cleaned markup) or the source differs. |
The same document in every run, on the same scale. Click a bar to open that chunk.
03 · Storage Engine heading-aware · 120 words
> Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software.
A write travels through three stages before it becomes part of a segment. First, it is appended to the write-ahead log. Second, it is inserted into the active memtable, a sorted in-memory structure. Third, when the memtable reaches `memtable_size`, it is frozen and written to disk as a new segment by a background thread, after which the matching part of the WAL can be deleted. The application only waits for the first two stages. The third happens in the background, which is why writes stay fast even while large segments are being written.
The durability level decides how far a write must travel before Quillstore acknowledges it. Choosing a level is a trade-off between speed and the amount of data you can lose in a crash.
| Level | Acknowledged after | Data lost on process crash | Data lost on power loss | |---|---|---|---| | `none` | Insert into memtable | Up to one memtable | Up to one memtable | | `flush` | Write to the OS page cache | Nothing | Up to a few seconds | | `fsync` | `fsync` of the WAL file | Nothing | Nothing | With `fsync`, Quillstore groups concurrent writes into one `fsync` call, so the cost per write falls as the number of writers grows. A single writer on a typical SSD reaches a few thousand durable writes per second; sixteen writers reach several times that.
A read checks the active memtable, then the frozen memtables, then the segments from newest to oldest. It stops at the first version it finds. Each segment has a Bloom filter, so most segments that do not contain the key are skipped without reading from disk. Range scans merge all of these sources at once. They are efficient when the range is narrow or when compaction keeps the number of overlapping segments small.
Segments are immutable, so overwritten and deleted keys keep taking space until compaction merges segments and drops the old versions. Quillstore offers two strategies, chosen per keyspace.
Leveled compaction organizes segments into levels, each ten times larger than the previous one. Within a level, segments do not overlap, so a read touches at most one segment per level. The cost is higher write amplification: a key may be rewritten once per level as it moves down. Use leveled compaction for read-heavy keyspaces and for keyspaces where keys are overwritten often.
Tiered compaction waits until several segments of similar size exist and merges them together. It writes each key fewer times, so it is cheaper for write-heavy workloads, but reads may have to check more segments and temporary disk usage is higher. Use tiered compaction for append-heavy keyspaces such as event logs and for data with a short time-to-live.
| Property | Leveled | Tiered | |---|---|---| | Write amplification | High (10–30×) | Low (3–6×) | | Read amplification | Low | Medium | | Space amplification | About 1.1× | Up to 2× | | Best for | Reads, updates | Appends, expiring data | | Default for | `sessions`, `config` | `events`, `metrics` |
Deleting a key writes a tombstone, a small marker that hides older versions. Tombstones are removed by compaction once no older version of the key remains in any segment. Keys with a time-to-live expire the same way: they become invisible to readers at expiry and are physically removed during the next compaction that touches them. A keyspace with many deletes and little compaction can accumulate tombstones and slow down range scans. The `quill stats` command reports the tombstone ratio for each keyspace; above 30 %, consider a manual compaction.
Values larger than `blob_threshold` are written to separate blob files, and the segment stores only a pointer. This keeps segments small and makes compaction cheaper, because large values are not rewritten when their keys move between levels. Blob files are garbage-collected when the share of unreferenced values in a file exceeds 50 %.
Every WAL entry and every segment block carries a checksum. A mismatch on read fails the read with a `CorruptBlock` error instead of returning damaged data. The store keeps running, and the error message names the segment file, so you can restore that file from a replica or a backup. The following script verifies every segment of a store offline and prints the files that need attention:
```bash
#!/usr/bin/env bash
# Verify every segment of a stopped store and list damaged files.
set -euo pipefail
STORE_DIR=${1:?usage: verify.sh STORE_DIR}
quill verify --store "$STORE_DIR" --format json > /tmp/verify.json
damaged=$(jq -r '.segments[] | select(.status != "ok") | .file' /tmp/verify.json)
if [ -z "$damaged" ]; then
echo "All segments are healthy."
exit 0
fi
echo "Damaged segments:"
for file in $damaged; do
size=$(stat -c %s "$STORE_DIR/$file" 2>/dev/null || stat -f %z "$STORE_DIR/$file")
echo " $file ($size bytes)"
done
echo "Restore these files from a replica: quill restore-segment --from PEER FILE"
exit 1
```
Run the script while the store is closed. Verifying a store that is being written to may report segments that are still being created as incomplete.| Severity | Where | Check | Message |
|---|---|---|---|
| ▲ warning | document | gaps | 191 non-whitespace characters in 11 place(s) are not in any chunk, so they cannot be retrieved. This is expected only if your chunker deliberately drops text (headings kept as metadata, boilerplate). |
The same document in every run, on the same scale. Click a bar to open that chunk.
04 · Replication heading-aware · 120 words
> Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software.
A replicated Quillstore group has one leader and one or more followers. Only the leader accepts writes. It appends each write to its WAL and ships the new WAL entries to every follower, which append them to their own WAL and apply them to their memtable. A write is acknowledged once a quorum of peers, including the leader, has stored it according to the durability level. Followers can serve reads. Those reads may be slightly behind the leader; see the consistency levels below.
Every peer lists all peers, including itself, in the `peers` option. The order does not matter. ```toml [store] peers = ["10.0.0.11:7400", "10.0.0.12:7400", "10.0.0.13:7400"] quorum = "majority" election_timeout = "1500ms" ``` Start the peers in any order. When a majority can reach each other, they elect a leader, and the group starts accepting writes. A group of three tolerates one failed peer; a group of five tolerates two.
Peers exchange heartbeats every `election_timeout / 5`. When a follower misses heartbeats for a full `election_timeout`, it becomes a candidate and asks the others for votes. A peer votes for a candidate only if the candidate's log is at least as complete as its own, which guarantees that a new leader never loses acknowledged writes. During an election, writes fail with `NoLeader` and should be retried. Elections usually finish within two election timeouts.
Reads accept a consistency level that trades freshness for latency.
| Level | Served by | Guarantee | Typical latency | |---|---|---|---| | `local` | Any peer | May return stale data | Lowest | | `bounded` | Any peer | At most `max_lag` behind the leader | Low | | `leader` | The leader | Sees all acknowledged writes | Medium | | `linearizable` | The leader, after a quorum check | Sees all writes acknowledged before the read started | Highest | Use `leader` by default. Use `local` for caches and dashboards that tolerate stale data, and `linearizable` only for reads that must observe a write made by another client a moment earlier.
The table below lists the failures a group handles automatically and those that need an operator.
- ▲ warning Ends inside a table: the table continues in the next chunk.
| Failure | Detected by | Automatic response | Operator action | |---|---|---|---| | Follower crash | Missing heartbeat replies | Leader keeps serving with remaining quorum | Restart the follower; it catches up from the leader | | Leader crash | Followers miss heartbeats | New leader elected | Restart the old leader; it rejoins as a follower | | Network partition | Missing heartbeats on both sides | Minority side stops accepting writes | Fix the network; the minority catches up | | Slow disk on a follower | Growing replication lag | Leader throttles shipping to that follower | Replace the disk or remove the peer |
- ℹ info Only 79% of the text was found in the source: the chunker transformed it (added headers or context, cleaned markup) or the source differs.
| Failure | Detected by | Automatic response | Operator action | |---|---|---|---| | Disk failure | `CorruptBlock` or I/O errors | Peer stops and reports the failed path | Follow the node recovery runbook | | Lost quorum | No leader can be elected | Group becomes read-only | Restore failed peers or force a new configuration |
Peers are added and removed one at a time with `quill peers add` and `quill peers remove`. Each change is itself replicated, so it only takes effect once a quorum has stored it. Never edit the `peers` option of a running group by hand: peers with different lists can elect two leaders.
The leader tracks how far behind each follower is, in WAL entries and in bytes. `quill status` shows the lag for each peer. A lag that keeps growing means the follower cannot keep up, usually because of a slow disk or a saturated network link. Short spikes during compaction are normal.
| Severity | Where | Check | Message |
|---|---|---|---|
| ▲ warning | document | gaps | 135 non-whitespace characters in 8 place(s) are not in any chunk, so they cannot be retrieved. This is expected only if your chunker deliberately drops text (headings kept as metadata, boilerplate). |
| ▲ warning | #7 | ends_in_table | Ends inside a table: the table continues in the next chunk. |
| ℹ info | #8 | partial | Only 79% of the text was found in the source: the chunker transformed it (added headers or context, cleaned markup) or the source differs. |
The same document in every run, on the same scale. Click a bar to open that chunk.
05 · Operations Runbook heading-aware · 120 words
> Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software.
> **Warning:** commands in this runbook change data on disk. Run them on one peer at a time, and only after taking a backup or confirming that the other peers are healthy. Each procedure lists its symptoms, the checks to run, and the steps to fix the problem. Run the checks first: several symptoms look alike but need different fixes.
The peer stops and logs `I/O error` or `CorruptBlock` with a file path. `quill status` on another peer shows it as unreachable, and the group keeps serving writes if a quorum remains.
1. Confirm that the remaining peers still form a quorum: `quill status --peer 10.0.0.12:7400`. 2. Check the kernel log of the failed machine for disk errors: `dmesg | grep -i error`. 3. If the disk is still readable, run the verification script from the storage engine guide to list damaged segments.
If only a few segments are damaged and the disk is healthy, restore those segments from a peer: ```bash quill restore-segment --from 10.0.0.12:7400 --store /var/lib/myapp/store 000123.seg quill verify --store /var/lib/myapp/store ``` If the disk has failed, replace it and rebuild the peer from scratch: ```bash # On the new, empty disk mkdir -p /var/lib/myapp/store quill bootstrap --from 10.0.0.12:7400 --store /var/lib/myapp/store systemctl start myapp ``` `quill bootstrap` copies the newest segments from a healthy peer and then replays the WAL entries written since. For a 200 GB store on a 1 Gbit/s link, expect about 30 minutes. The peer rejoins the group automatically when it has caught up.
> **Warning:** commands in this runbook change data on disk. Run them on one peer at a time, and only after taking a backup or confirming that the other peers are healthy.
`quill backup` creates a consistent copy of a running store without stopping it. It opens a snapshot, copies the segments it references and the WAL up to the snapshot's sequence number, and writes a manifest. ```bash quill backup --store /var/lib/myapp/store --to /backups/store-$(date +%F) ``` Backups are incremental by default: segments already present in the previous backup are hard-linked instead of copied.
Restoring replaces the whole store. Stop the application, move the current directory aside, and restore: ```bash systemctl stop myapp mv /var/lib/myapp/store /var/lib/myapp/store.old quill restore --from /backups/store-2026-11-30 --to /var/lib/myapp/store systemctl start myapp ``` In a replicated group, restore a backup on one peer only, then rebuild the other peers from it with `quill bootstrap`.
Quillstore exposes metrics on `/metrics` when `metrics_port` is set. The most useful ones are listed below.
| Metric | Meaning | Alert when | |---|---|---| | `quill_write_latency_seconds` | Time to acknowledge a write | p99 above 50 ms for 10 minutes | | `quill_read_latency_seconds` | Time to serve a read | p99 above 20 ms for 10 minutes | | `quill_compaction_pending_bytes` | Data waiting to be compacted | Growing for more than an hour | | `quill_tombstone_ratio` | Share of tombstones in scanned data | Above 0.3 | | `quill_replication_lag_entries` | WAL entries a follower is behind | Above 100 000 for 5 minutes | | `quill_disk_free_bytes` | Free space on the data volume | Below twice the dataset size | | `quill_corrupt_blocks_total` | Checksum failures since start | Any increase |
When write latency rises, check the compaction backlog first. If `quill_compaction_pending_bytes` keeps growing, compaction cannot keep up with the write rate: add compaction threads, move write-heavy keyspaces to tiered compaction, or reduce the write rate. If the backlog is stable, check the disk with `iostat -x 5` for saturation.
Compaction needs free space to write new segments before deleting old ones. When free space falls below the size of the largest compaction, Quillstore stops compacting and logs `compaction paused: disk full`. Free space by lowering retention on large keyspaces, deleting old backups from the same volume, or moving blob files to another disk with `quill move-blobs`.
| Severity | Where | Check | Message |
|---|---|---|---|
| ▲ warning | document | gaps | 195 non-whitespace characters in 10 place(s) are not in any chunk, so they cannot be retrieved. This is expected only if your chunker deliberately drops text (headings kept as metadata, boilerplate). |
The same document in every run, on the same scale. Click a bar to open that chunk.
06 · HTTP API Reference heading-aware · 120 words
> Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software.
The optional HTTP API lets other processes read and write a store. Enable it with `http_port`. All requests and responses use JSON, keys and values are base64-encoded, and every response carries the store's current sequence number in the `X-Quill-Sequence` header.
| Method | Path | Description |
|---|---|---|
| `GET` | `/v2/keyspaces/{ks}/keys/{key}` | Read the latest version of a key |
| `PUT` | `/v2/keyspaces/{ks}/keys/{key}` | Write a value |
| `DELETE` | `/v2/keyspaces/{ks}/keys/{key}` | Delete a key |
| `POST` | `/v2/keyspaces/{ks}/scan` | Read a range of keys |
| `POST` | `/v2/transactions` | Apply several writes atomically |
| `GET` | `/v2/status` | Peer role, sequence number and lag |
| `GET` | `/v2/keyspaces` | List keyspaces and their settings |```http
GET /v2/keyspaces/sessions/keys/dXNlcjo0Mg== HTTP/1.1
Accept: application/json
X-Quill-Consistency: leader
```
```json
{
"key": "dXNlcjo0Mg==",
"value": "eyJuYW1lIjogIkFkYSJ9",
"sequence": 918273,
"expires_at": "2026-12-02T10:00:00Z"
}
```
A missing key returns `404` with the error code `KeyNotFound`. The consistency header is optional and defaults to `leader`.A transaction applies all of its operations or none of them. Operations are applied in order, and a `check` operation fails the whole transaction if a key does not have the expected sequence number, which is how you implement compare-and-set.
```json
{
"operations": [
{"op": "check", "keyspace": "config", "key": "ZmVhdHVyZXM=", "sequence": 41},
{"op": "put", "keyspace": "config", "key": "ZmVhdHVyZXM=", "value": "eyJkYXJrIjogdHJ1ZX0="},
{"op": "delete", "keyspace": "sessions", "key": "dXNlcjo0Mw=="}
]
}
```- ▲ warning Ends inside a table: the table continues in the next chunk.
| Status | Code | Meaning | Retry? | |---|---|---|---| | `400` | `BadRequest` | The request body or a parameter is invalid | No | | `404` | `KeyNotFound` | The key does not exist or has expired | No | | `409` | `CheckFailed` | A `check` operation did not match | After re-reading | | `413` | `BatchTooLarge` | The transaction exceeds `max_batch_bytes` | No; split it | | `423` | `ReadOnly` | The group has lost quorum | Yes, with backoff | | `500` | `CorruptBlock` | A checksum failed while reading | No; see the runbook | | `503` | `NoLeader` | An election is in progress | Yes, after 1–3 s |
- ℹ info Only 64% of the text was found in the source: the chunker transformed it (added headers or context, cleaned markup) or the source differs.
| Status | Code | Meaning | Retry? | |---|---|---|---| | `504` | `Timeout` | The request exceeded `read_timeout` | Yes |
Scans return at most `limit` keys (default 1000) and a `next` cursor when more keys remain. Pass the cursor back unchanged to continue. Cursors are tied to a snapshot and expire after five minutes; an expired cursor returns `400` with the code `CursorExpired`.
The HTTP API supports bearer tokens. Set `http_tokens_file` to a file with one token per line; requests without a valid `Authorization: Bearer` header receive `401`. Tokens are compared in constant time and never logged. For anything beyond a trusted network, put the API behind a TLS-terminating proxy.
| Severity | Where | Check | Message |
|---|---|---|---|
| ▲ warning | document | gaps | 121 non-whitespace characters in 8 place(s) are not in any chunk, so they cannot be retrieved. This is expected only if your chunker deliberately drops text (headings kept as metadata, boilerplate). |
| ▲ warning | #5 | ends_in_table | Ends inside a table: the table continues in the next chunk. |
| ℹ info | #6 | partial | Only 64% of the text was found in the source: the chunker transformed it (added headers or context, cleaned markup) or the source differs. |
The same document in every run, on the same scale. Click a bar to open that chunk.
07 · Release Notes heading-aware · 120 words
No chunks.
| Severity | Where | Check | Message |
|---|---|---|---|
| ▲ warning | document | no_chunks | This document produced no chunks: none of its text will be retrievable. |
| ▲ warning | document | gaps | 626 non-whitespace characters in 1 place(s) are not in any chunk, so they cannot be retrieved. This is expected only if your chunker deliberately drops text (headings kept as metadata, boilerplate). |
The same document in every run, on the same scale. Click a bar to open that chunk.
(chunks without a matching source) heading-aware · 120 words
The v1 API used XML payloads and has been removed.
| Severity | Where | Check | Message |
|---|---|---|---|
| ℹ info | document | no_source | These chunks are listed but not placed: they could not be matched to a source document. Pass source= or sources= to see them in context. |
01 · Quillstore Overview fixed-size · 780 chars, 130 overlap
- ✕ error 123 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Ends in the middle of a word.
# Quillstore Overview > Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software. ## What Quillstore Is Quillstore is an embedded, persistent key-value store for services that need fast local reads and durable writes without running a separate database server. It links into your application as a library, stores data in a single directory, and can optionally replicate that directory to two or more peers. Quillstore is designed for three workloads: session and cache data that must survive restarts, event logs that are written once and read in order, and configuration snapshots that change rarely but must be identical on every node. ## Core Concepts ### Keyspaces A keyspace is a named collection of ke
- ✕ error 138 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Starts in the middle of a word.
- ▲ warning Ends in the middle of a word.
s that change rarely but must be identical on every node. ## Core Concepts ### Keyspaces A keyspace is a named collection of keys with its own settings. Each keyspace chooses a compaction strategy, a compression codec and a retention policy. Keys are byte strings of up to 4 KiB; values can be up to 64 MiB, although values above 1 MiB are stored out of line in blob files. ### Records and Versions Every write creates a new version of a record. A version carries a 64-bit sequence number assigned by the writer, a timestamp, and an optional time-to-live. Readers see the latest version unless they open a snapshot, which pins the sequence number at the moment it was created. ### The Write-Ahead Log Before a write is acknowledged, it is appended to the write-ahead log (W
- ✕ error 131 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Starts in the middle of a word.
- ▲ warning Ends in the middle of a word.
r at the moment it was created. ### The Write-Ahead Log Before a write is acknowledged, it is appended to the write-ahead log (WAL) and, depending on the durability level, flushed to disk. The WAL is the only structure that must be written synchronously; everything else is rebuilt from it after a crash. ### Segments Data on disk lives in immutable segment files. A segment holds sorted keys, a sparse index and a Bloom filter. Segments are merged in the background by compaction, which discards overwritten and expired versions. ## Architecture at a Glance A Quillstore node has four layers. The table below lists them from the application down to the disk. | Layer | Responsibility | Main settings | |---|---|---| | API | Get, put, delete, scan, transactions | `max_batc
- ✕ error 125 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning The chunk's own offsets do not match the source; it was located by search instead.
- ▲ warning Starts in the middle of a word.
- ▲ warning Ends in the middle of a word.
wn to the disk. | Layer | Responsibility | Main settings | |---|---|---| | API | Get, put, delete, scan, transactions | `max_batch_bytes`, `read_timeout` | | Memtable | In-memory sorted buffer for recent writes | `memtable_size`, `memtable_count` | | Storage engine | WAL, segments, compaction, blob files | `durability`, `compaction`, `codec` | | Replication | Log shipping to peers, leader election | `peers`, `quorum`, `election_timeout` | Each layer can be tuned independently, but the defaults are chosen to work well together for small and medium datasets of up to a few hundred gigabytes per node. ## When Not to Use Quillstore Quillstore is not a relational database. It has no query planner, no joins and no secondary indexes beyond what you build yourself with addit
- ✕ error 140 words, over the limit of 120. Embedding models truncate the rest.
- ℹ info Ends in the middle of a sentence.
is not a relational database. It has no query planner, no joins and no secondary indexes beyond what you build yourself with additional keyspaces. It is also not designed for datasets that do not fit on one machine: replication copies the whole dataset to every peer instead of sharding it. If you need ad-hoc queries across many fields, or a dataset that grows beyond a single node's disk, use a dedicated database server instead. ## Glossary | Term | Meaning | |---|---| | Blob file | A file holding large values outside the segments | | Compaction | Background merging of segments to reclaim space | | Durability level | How far a write must travel before it is acknowledged | | Leader | The peer that accepts writes in a replicated group | | Memtable | The in-memory buffer
- ▲ warning Starts in the middle of a word.
avel before it is acknowledged | | Leader | The peer that accepts writes in a replicated group | | Memtable | The in-memory buffer of recent writes | | Quorum | The number of peers that must confirm a replicated write | | Segment | An immutable sorted file of keys and values | | Snapshot | A consistent read view pinned to one sequence number | | Tombstone | A marker that records the deletion of a key | | WAL | Write-ahead log, the append-only record of every write |
| Severity | Where | Check | Message |
|---|---|---|---|
| ✕ error | #0 | over_limit | 123 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #1 | over_limit | 138 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #2 | over_limit | 131 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #3 | over_limit | 125 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #4 | over_limit | 140 words, over the limit of 120. Embedding models truncate the rest. |
| ▲ warning | #0 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #1 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #1 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #2 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #2 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #3 | offset_mismatch | The chunk's own offsets do not match the source; it was located by search instead. |
| ▲ warning | #3 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #3 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #5 | starts_mid_word | Starts in the middle of a word. |
| ℹ info | #4 | ends_mid_sentence | Ends in the middle of a sentence. |
The same document in every run, on the same scale. Click a bar to open that chunk.
02 · Installation and Configuration fixed-size · 780 chars, 130 overlap
# Installation and Configuration > Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software. ## Requirements Quillstore runs on 64-bit Linux and macOS. It needs a filesystem that supports `fsync` on directories, which rules out some network filesystems. For production, use a local SSD and reserve at least twice the size of your dataset, because compaction temporarily needs room for both the old and the new segments. ## Installing the Library The library is published for Python, Go and Rust. Pick the package for your language: ```bash pip install quillstore # Python 3.10 or newer go get example.org/quillstore/v2 # Go 1.22 or newer cargo add quillstore # Rust 2021 edition ```
- ▲ warning Cuts a code block: the opening or closing ``` fence is in another chunk.
- ▲ warning Starts in the middle of a word.
- ▲ warning Ends in the middle of a word.
thon 3.10 or newer
go get example.org/quillstore/v2 # Go 1.22 or newer
cargo add quillstore # Rust 2021 edition
```
The command-line tool, `quill`, is installed with the Python package. It is used for inspection, backups and recovery and never needs to run while your application is running.
## Opening a Store
A store is opened on a directory. If the directory is empty, Quillstore creates the files it needs.
```python
import quillstore
store = quillstore.open(
"/var/lib/myapp/store",
durability="fsync",
memtable_size="64MiB",
)
with store.transaction() as tx:
tx.put(b"user:42", b'{"name": "Ada"}')
tx.put(b"user:43", b'{"name": "Grace"}')
print(store.get(b"user:42"))
store.close()
```
Always close the store before the process exit- ▲ warning Cuts a code block: the opening or closing ``` fence is in another chunk.
- ℹ info Ends in the middle of a sentence.
(b"user:43", b'{"name": "Grace"}')
print(store.get(b"user:42"))
store.close()
```
Always close the store before the process exits. Closing flushes the memtable and writes a clean-shutdown marker, which makes the next start faster because the WAL does not need to be replayed.
## Configuration File
Instead of passing options in code, you can keep them in a `quillstore.toml` file next to the data directory. Options passed in code override the file.
```toml
[store]
durability = "fsync"
memtable_size = "64MiB"
memtable_count = 2
[keyspace.sessions]
compaction = "tiered"
codec = "lz4"
ttl = "24h"
[keyspace.events]
compaction = "leveled"
codec = "zstd"
retention = "30d"
```
## Configuration Reference
The table below lists every store-level option, its default and when- ✕ error 138 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Cuts a code block: the opening or closing ``` fence is in another chunk.
- ▲ warning Starts in the middle of a word.
- ▲ warning Ends inside a table: the table continues in the next chunk.
c = "zstd" retention = "30d" ``` ## Configuration Reference The table below lists every store-level option, its default and when to change it. | Option | Default | Description | |---|---|---| | `durability` | `fsync` | `none`, `flush` or `fsync`; see the storage engine guide | | `memtable_size` | `32MiB` | Size at which a memtable is frozen and written to a segment | | `memtable_count` | `2` | Number of memtables kept in memory, including frozen ones | | `max_batch_bytes` | `4MiB` | Largest batch a single transaction may write | | `read_timeout` | `2s` | Time a read waits for a lock before failing | | `compaction_threads` | `2` | Background threads used for compaction | | `blob_threshold` | `1MiB` | Values above this size are stored in blob files | | `codec` | `lz4`
- ✕ error 135 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Starts in the middle of a word.
- ▲ warning Ends in the middle of a word.
d threads used for compaction | | `blob_threshold` | `1MiB` | Values above this size are stored in blob files | | `codec` | `lz4` | Default compression: `none`, `lz4` or `zstd` | | `bloom_bits_per_key` | `10` | Bloom filter size; higher means fewer false positives | | `cache_size` | `256MiB` | Block cache shared by all keyspaces | | `max_open_files` | `1000` | Segment files kept open at the same time | | `checksum` | `crc32c` | Checksum used for WAL entries and segment blocks | | `peers` | empty | Addresses of replication peers | | `quorum` | `majority` | Peers that must confirm a replicated write | | `election_timeout` | `1500ms` | Time without a heartbeat before peers elect a new leader | Most applications only change `durability`, `memtable_size` and `cache_size`. T
- ✕ error 121 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Starts in the middle of a word.
- ▲ warning Ends in the middle of a word.
out a heartbeat before peers elect a new leader | Most applications only change `durability`, `memtable_size` and `cache_size`. The others exist for unusual workloads and are safe to leave at their defaults. ## Environment Variables Two environment variables are read at startup. `QUILL_LOG` sets the log level (`error`, `warn`, `info` or `debug`), and `QUILL_CONFIG` points to a configuration file in a different location. Environment variables never override options passed in code. ## Upgrading Quillstore reads data written by the previous two minor versions. To upgrade across more versions, upgrade one step at a time and open the store once at each step, which converts the segment format. Never downgrade a store that has been opened by a newer version: older version
- ▲ warning Starts in the middle of a word.
ce at each step, which converts the segment format. Never downgrade a store that has been opened by a newer version: older versions refuse to open it, to prevent silent data loss.
| Severity | Where | Check | Message |
|---|---|---|---|
| ✕ error | #3 | over_limit | 138 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #4 | over_limit | 135 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #5 | over_limit | 121 words, over the limit of 120. Embedding models truncate the rest. |
| ▲ warning | #1 | split_code_block | Cuts a code block: the opening or closing ``` fence is in another chunk. |
| ▲ warning | #1 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #1 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #2 | split_code_block | Cuts a code block: the opening or closing ``` fence is in another chunk. |
| ▲ warning | #3 | split_code_block | Cuts a code block: the opening or closing ``` fence is in another chunk. |
| ▲ warning | #3 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #3 | ends_in_table | Ends inside a table: the table continues in the next chunk. |
| ▲ warning | #4 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #4 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #5 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #5 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #6 | starts_mid_word | Starts in the middle of a word. |
| ℹ info | #2 | ends_mid_sentence | Ends in the middle of a sentence. |
The same document in every run, on the same scale. Click a bar to open that chunk.
03 · Storage Engine fixed-size · 780 chars, 130 overlap
- ✕ error 130 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Ends in the middle of a word.
# Storage Engine > Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software. ## The Write Path A write travels through three stages before it becomes part of a segment. First, it is appended to the write-ahead log. Second, it is inserted into the active memtable, a sorted in-memory structure. Third, when the memtable reaches `memtable_size`, it is frozen and written to disk as a new segment by a background thread, after which the matching part of the WAL can be deleted. The application only waits for the first two stages. The third happens in the background, which is why writes stay fast even while large segments are being written. ## Durability Levels The durability level decides how far a write mu
- ✕ error 148 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Starts in the middle of a word.
- ▲ warning Ends in the middle of a word.
ites stay fast even while large segments are being written. ## Durability Levels The durability level decides how far a write must travel before Quillstore acknowledges it. Choosing a level is a trade-off between speed and the amount of data you can lose in a crash. | Level | Acknowledged after | Data lost on process crash | Data lost on power loss | |---|---|---|---| | `none` | Insert into memtable | Up to one memtable | Up to one memtable | | `flush` | Write to the OS page cache | Nothing | Up to a few seconds | | `fsync` | `fsync` of the WAL file | Nothing | Nothing | With `fsync`, Quillstore groups concurrent writes into one `fsync` call, so the cost per write falls as the number of writers grows. A single writer on a typical SSD reaches a few thousand durable w
- ✕ error 133 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Starts in the middle of a word.
all, so the cost per write falls as the number of writers grows. A single writer on a typical SSD reaches a few thousand durable writes per second; sixteen writers reach several times that. ## The Read Path A read checks the active memtable, then the frozen memtables, then the segments from newest to oldest. It stops at the first version it finds. Each segment has a Bloom filter, so most segments that do not contain the key are skipped without reading from disk. Range scans merge all of these sources at once. They are efficient when the range is narrow or when compaction keeps the number of overlapping segments small. ## Compaction Segments are immutable, so overwritten and deleted keys keep taking space until compaction merges segments and drops the old versions.
- ✕ error 123 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Starts in the middle of a word.
- ▲ warning Ends in the middle of a word.
nts are immutable, so overwritten and deleted keys keep taking space until compaction merges segments and drops the old versions. Quillstore offers two strategies, chosen per keyspace. ### Leveled Compaction Leveled compaction organizes segments into levels, each ten times larger than the previous one. Within a level, segments do not overlap, so a read touches at most one segment per level. The cost is higher write amplification: a key may be rewritten once per level as it moves down. Use leveled compaction for read-heavy keyspaces and for keyspaces where keys are overwritten often. ### Tiered Compaction Tiered compaction waits until several segments of similar size exist and merges them together. It writes each key fewer times, so it is cheaper for write-heavy wor
- ✕ error 136 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Starts in the middle of a word.
- ▲ warning Ends in the middle of a word.
eral segments of similar size exist and merges them together. It writes each key fewer times, so it is cheaper for write-heavy workloads, but reads may have to check more segments and temporary disk usage is higher. Use tiered compaction for append-heavy keyspaces such as event logs and for data with a short time-to-live. ### Comparing the Strategies | Property | Leveled | Tiered | |---|---|---| | Write amplification | High (10–30×) | Low (3–6×) | | Read amplification | Low | Medium | | Space amplification | About 1.1× | Up to 2× | | Best for | Reads, updates | Appends, expiring data | | Default for | `sessions`, `config` | `events`, `metrics` | ## Tombstones and Expiry Deleting a key writes a tombstone, a small marker that hides older versions. Tombstones are remo
- ✕ error 125 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Starts in the middle of a word.
- ▲ warning Ends in the middle of a word.
ics` | ## Tombstones and Expiry Deleting a key writes a tombstone, a small marker that hides older versions. Tombstones are removed by compaction once no older version of the key remains in any segment. Keys with a time-to-live expire the same way: they become invisible to readers at expiry and are physically removed during the next compaction that touches them. A keyspace with many deletes and little compaction can accumulate tombstones and slow down range scans. The `quill stats` command reports the tombstone ratio for each keyspace; above 30 %, consider a manual compaction. ## Blob Files Values larger than `blob_threshold` are written to separate blob files, and the segment stores only a pointer. This keeps segments small and makes compaction cheaper, because la
- ✕ error 129 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Cuts a code block: the opening or closing ``` fence is in another chunk.
- ▲ warning Ends in the middle of a word.
to separate blob files, and the segment stores only a pointer. This keeps segments small and makes compaction cheaper, because large values are not rewritten when their keys move between levels. Blob files are garbage-collected when the share of unreferenced values in a file exceeds 50 %. ## Checksums and Corruption Every WAL entry and every segment block carries a checksum. A mismatch on read fails the read with a `CorruptBlock` error instead of returning damaged data. The store keeps running, and the error message names the segment file, so you can restore that file from a replica or a backup. The following script verifies every segment of a store offline and prints the files that need attention: ```bash #!/usr/bin/env bash # Verify every segment of a stopped sto
- ▲ warning Ends in the middle of a word.
of a store offline and prints the files that need attention:
```bash
#!/usr/bin/env bash
# Verify every segment of a stopped store and list damaged files.
set -euo pipefail
STORE_DIR=${1:?usage: verify.sh STORE_DIR}
quill verify --store "$STORE_DIR" --format json > /tmp/verify.json
damaged=$(jq -r '.segments[] | select(.status != "ok") | .file' /tmp/verify.json)
if [ -z "$damaged" ]; then
echo "All segments are healthy."
exit 0
fi
echo "Damaged segments:"
for file in $damaged; do
size=$(stat -c %s "$STORE_DIR/$file" 2>/dev/null || stat -f %z "$STORE_DIR/$file")
echo " $file ($size bytes)"
done
echo "Restore these files from a replica: quill restore-segment --from PEER FILE"
exit 1
```
Run the script while the store is closed. Verifying a store that is bei- ▲ warning Cuts a code block: the opening or closing ``` fence is in another chunk.
- ▲ warning Starts in the middle of a word.
plica: quill restore-segment --from PEER FILE" exit 1 ``` Run the script while the store is closed. Verifying a store that is being written to may report segments that are still being created as incomplete.
| Severity | Where | Check | Message |
|---|---|---|---|
| ✕ error | #0 | over_limit | 130 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #1 | over_limit | 148 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #2 | over_limit | 133 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #3 | over_limit | 123 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #4 | over_limit | 136 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #5 | over_limit | 125 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #6 | over_limit | 129 words, over the limit of 120. Embedding models truncate the rest. |
| ▲ warning | #0 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #1 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #1 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #2 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #3 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #3 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #4 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #4 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #5 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #5 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #6 | split_code_block | Cuts a code block: the opening or closing ``` fence is in another chunk. |
| ▲ warning | #6 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #7 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #8 | split_code_block | Cuts a code block: the opening or closing ``` fence is in another chunk. |
| ▲ warning | #8 | starts_mid_word | Starts in the middle of a word. |
The same document in every run, on the same scale. Click a bar to open that chunk.
04 · Replication fixed-size · 780 chars, 130 overlap
- ✕ error 129 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Cuts a code block: the opening or closing ``` fence is in another chunk.
- ℹ info Ends in the middle of a sentence.
# Replication > Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software. ## How Replication Works A replicated Quillstore group has one leader and one or more followers. Only the leader accepts writes. It appends each write to its WAL and ships the new WAL entries to every follower, which append them to their own WAL and apply them to their memtable. A write is acknowledged once a quorum of peers, including the leader, has stored it according to the durability level. Followers can serve reads. Those reads may be slightly behind the leader; see the consistency levels below. ## Setting Up a Group Every peer lists all peers, including itself, in the `peers` option. The order does not matter. ```toml
- ✕ error 126 words, over the limit of 120. Embedding models truncate the rest.
- ℹ info Ends in the middle of a sentence.
## Setting Up a Group Every peer lists all peers, including itself, in the `peers` option. The order does not matter. ```toml [store] peers = ["10.0.0.11:7400", "10.0.0.12:7400", "10.0.0.13:7400"] quorum = "majority" election_timeout = "1500ms" ``` Start the peers in any order. When a majority can reach each other, they elect a leader, and the group starts accepting writes. A group of three tolerates one failed peer; a group of five tolerates two. ## Leader Election Peers exchange heartbeats every `election_timeout / 5`. When a follower misses heartbeats for a full `election_timeout`, it becomes a candidate and asks the others for votes. A peer votes for a candidate only if the candidate's log is at least as complete as its own, which guarantees that a new leader
- ✕ error 138 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Starts in the middle of a word.
- ℹ info Ends in the middle of a sentence.
s. A peer votes for a candidate only if the candidate's log is at least as complete as its own, which guarantees that a new leader never loses acknowledged writes. During an election, writes fail with `NoLeader` and should be retried. Elections usually finish within two election timeouts. ## Consistency Levels Reads accept a consistency level that trades freshness for latency. | Level | Served by | Guarantee | Typical latency | |---|---|---|---| | `local` | Any peer | May return stale data | Lowest | | `bounded` | Any peer | At most `max_lag` behind the leader | Low | | `leader` | The leader | Sees all acknowledged writes | Medium | | `linearizable` | The leader, after a quorum check | Sees all writes acknowledged before the read started | Highest | Use `leader` by
- ✕ error 133 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Starts in the middle of a word.
- ▲ warning Ends in the middle of a word.
nearizable` | The leader, after a quorum check | Sees all writes acknowledged before the read started | Highest | Use `leader` by default. Use `local` for caches and dashboards that tolerate stale data, and `linearizable` only for reads that must observe a write made by another client a moment earlier. ## Failure Modes The table below lists the failures a group handles automatically and those that need an operator. | Failure | Detected by | Automatic response | Operator action | |---|---|---|---| | Follower crash | Missing heartbeat replies | Leader keeps serving with remaining quorum | Restart the follower; it catches up from the leader | | Leader crash | Followers miss heartbeats | New leader elected | Restart the old leader; it rejoins as a follower | | Network p
- ✕ error 144 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Ends in the middle of a word.
| | Leader crash | Followers miss heartbeats | New leader elected | Restart the old leader; it rejoins as a follower | | Network partition | Missing heartbeats on both sides | Minority side stops accepting writes | Fix the network; the minority catches up | | Slow disk on a follower | Growing replication lag | Leader throttles shipping to that follower | Replace the disk or remove the peer | | Disk failure | `CorruptBlock` or I/O errors | Peer stops and reports the failed path | Follow the node recovery runbook | | Lost quorum | No leader can be elected | Group becomes read-only | Restore failed peers or force a new configuration | ## Changing Membership Peers are added and removed one at a time with `quill peers add` and `quill peers remove`. Each change is itself re
- ▲ warning Starts in the middle of a word.
ng Membership Peers are added and removed one at a time with `quill peers add` and `quill peers remove`. Each change is itself replicated, so it only takes effect once a quorum has stored it. Never edit the `peers` option of a running group by hand: peers with different lists can elect two leaders. ## Replication Lag The leader tracks how far behind each follower is, in WAL entries and in bytes. `quill status` shows the lag for each peer. A lag that keeps growing means the follower cannot keep up, usually because of a slow disk or a saturated network link. Short spikes during compaction are normal.
| Severity | Where | Check | Message |
|---|---|---|---|
| ✕ error | #0 | over_limit | 129 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #1 | over_limit | 126 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #2 | over_limit | 138 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #3 | over_limit | 133 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #4 | over_limit | 144 words, over the limit of 120. Embedding models truncate the rest. |
| ▲ warning | #0 | split_code_block | Cuts a code block: the opening or closing ``` fence is in another chunk. |
| ▲ warning | #2 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #3 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #3 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #4 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #5 | starts_mid_word | Starts in the middle of a word. |
| ℹ info | #0 | ends_mid_sentence | Ends in the middle of a sentence. |
| ℹ info | #1 | ends_mid_sentence | Ends in the middle of a sentence. |
| ℹ info | #2 | ends_mid_sentence | Ends in the middle of a sentence. |
The same document in every run, on the same scale. Click a bar to open that chunk.
05 · Operations Runbook fixed-size · 780 chars, 130 overlap
- ✕ error 133 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Ends in the middle of a word.
# Operations Runbook > Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software. ## Before You Start > **Warning:** commands in this runbook change data on disk. Run them on one peer at a time, and only after taking a backup or confirming that the other peers are healthy. Each procedure lists its symptoms, the checks to run, and the steps to fix the problem. Run the checks first: several symptoms look alike but need different fixes. ## Recovering a Node After a Disk Failure ### Symptoms The peer stops and logs `I/O error` or `CorruptBlock` with a file path. `quill status` on another peer shows it as unreachable, and the group keeps serving writes if a quorum remains. ### Checks 1. Confirm that th
- ✕ error 126 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Cuts a code block: the opening or closing ``` fence is in another chunk.
- ℹ info Ends in the middle of a sentence.
` on another peer shows it as unreachable, and the group keeps serving writes if a quorum remains. ### Checks 1. Confirm that the remaining peers still form a quorum: `quill status --peer 10.0.0.12:7400`. 2. Check the kernel log of the failed machine for disk errors: `dmesg | grep -i error`. 3. If the disk is still readable, run the verification script from the storage engine guide to list damaged segments. ### Recovery Steps If only a few segments are damaged and the disk is healthy, restore those segments from a peer: ```bash quill restore-segment --from 10.0.0.12:7400 --store /var/lib/myapp/store 000123.seg quill verify --store /var/lib/myapp/store ``` If the disk has failed, replace it and rebuild the peer from scratch: ```bash # On the new, empty disk mkdir
- ✕ error 130 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Cuts a code block: the opening or closing ``` fence is in another chunk.
- ▲ warning Starts in the middle of a word.
- ℹ info Ends in the middle of a sentence.
ib/myapp/store ``` If the disk has failed, replace it and rebuild the peer from scratch: ```bash # On the new, empty disk mkdir -p /var/lib/myapp/store quill bootstrap --from 10.0.0.12:7400 --store /var/lib/myapp/store systemctl start myapp ``` `quill bootstrap` copies the newest segments from a healthy peer and then replays the WAL entries written since. For a 200 GB store on a 1 Gbit/s link, expect about 30 minutes. The peer rejoins the group automatically when it has caught up. > **Warning:** commands in this runbook change data on disk. Run them on one peer at a time, and only after taking a backup or confirming that the other peers are healthy. ## Backups ### Taking a Backup `quill backup` creates a consistent copy of a running store without stopping it. It
- ▲ warning Starts in the middle of a word.
- ▲ warning Ends in the middle of a word.
re healthy. ## Backups ### Taking a Backup `quill backup` creates a consistent copy of a running store without stopping it. It opens a snapshot, copies the segments it references and the WAL up to the snapshot's sequence number, and writes a manifest. ```bash quill backup --store /var/lib/myapp/store --to /backups/store-$(date +%F) ``` Backups are incremental by default: segments already present in the previous backup are hard-linked instead of copied. ### Restoring a Backup Restoring replaces the whole store. Stop the application, move the current directory aside, and restore: ```bash systemctl stop myapp mv /var/lib/myapp/store /var/lib/myapp/store.old quill restore --from /backups/store-2026-11-30 --to /var/lib/myapp/store systemctl start myapp ``` In a repl
- ✕ error 124 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Cuts a code block: the opening or closing ``` fence is in another chunk.
/lib/myapp/store.old quill restore --from /backups/store-2026-11-30 --to /var/lib/myapp/store systemctl start myapp ``` In a replicated group, restore a backup on one peer only, then rebuild the other peers from it with `quill bootstrap`. ## Monitoring Quillstore exposes metrics on `/metrics` when `metrics_port` is set. The most useful ones are listed below. | Metric | Meaning | Alert when | |---|---|---| | `quill_write_latency_seconds` | Time to acknowledge a write | p99 above 50 ms for 10 minutes | | `quill_read_latency_seconds` | Time to serve a read | p99 above 20 ms for 10 minutes | | `quill_compaction_pending_bytes` | Data waiting to be compacted | Growing for more than an hour | | `quill_tombstone_ratio` | Share of tombstones in scanned data | Above 0.3 | | `
- ✕ error 126 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Starts in the middle of a word.
o be compacted | Growing for more than an hour | | `quill_tombstone_ratio` | Share of tombstones in scanned data | Above 0.3 | | `quill_replication_lag_entries` | WAL entries a follower is behind | Above 100 000 for 5 minutes | | `quill_disk_free_bytes` | Free space on the data volume | Below twice the dataset size | | `quill_corrupt_blocks_total` | Checksum failures since start | Any increase | ## Slow Writes When write latency rises, check the compaction backlog first. If `quill_compaction_pending_bytes` keeps growing, compaction cannot keep up with the write rate: add compaction threads, move write-heavy keyspaces to tiered compaction, or reduce the write rate. If the backlog is stable, check the disk with `iostat -x 5` for saturation. ## Running Out of Disk Space
- ▲ warning Starts in the middle of a word.
r reduce the write rate. If the backlog is stable, check the disk with `iostat -x 5` for saturation. ## Running Out of Disk Space Compaction needs free space to write new segments before deleting old ones. When free space falls below the size of the largest compaction, Quillstore stops compacting and logs `compaction paused: disk full`. Free space by lowering retention on large keyspaces, deleting old backups from the same volume, or moving blob files to another disk with `quill move-blobs`.
| Severity | Where | Check | Message |
|---|---|---|---|
| ✕ error | #0 | over_limit | 133 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #1 | over_limit | 126 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #2 | over_limit | 130 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #4 | over_limit | 124 words, over the limit of 120. Embedding models truncate the rest. |
| ✕ error | #5 | over_limit | 126 words, over the limit of 120. Embedding models truncate the rest. |
| ▲ warning | #0 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #1 | split_code_block | Cuts a code block: the opening or closing ``` fence is in another chunk. |
| ▲ warning | #2 | split_code_block | Cuts a code block: the opening or closing ``` fence is in another chunk. |
| ▲ warning | #2 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #3 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #3 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #4 | split_code_block | Cuts a code block: the opening or closing ``` fence is in another chunk. |
| ▲ warning | #5 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #6 | starts_mid_word | Starts in the middle of a word. |
| ℹ info | #1 | ends_mid_sentence | Ends in the middle of a sentence. |
| ℹ info | #2 | ends_mid_sentence | Ends in the middle of a sentence. |
The same document in every run, on the same scale. Click a bar to open that chunk.
06 · HTTP API Reference fixed-size · 780 chars, 130 overlap
- ▲ warning Ends inside a table: the table continues in the next chunk.
# HTTP API Reference
> Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software.
## Overview
The optional HTTP API lets other processes read and write a store. Enable it with `http_port`. All requests and responses use JSON, keys and values are base64-encoded, and every response carries the store's current sequence number in the `X-Quill-Sequence` header.
## Endpoints
| Method | Path | Description |
|---|---|---|
| `GET` | `/v2/keyspaces/{ks}/keys/{key}` | Read the latest version of a key |
| `PUT` | `/v2/keyspaces/{ks}/keys/{key}` | Write a value |
| `DELETE` | `/v2/keyspaces/{ks}/keys/{key}` | Delete a key |
| `POST` | `/v2/keyspaces/{ks}/scan` | Read a range of keys |
| `POST` | `/v2/transactions`- ▲ warning Starts in the middle of a word.
- ▲ warning Ends in the middle of a word.
aces/{ks}/keys/{key}` | Delete a key |
| `POST` | `/v2/keyspaces/{ks}/scan` | Read a range of keys |
| `POST` | `/v2/transactions` | Apply several writes atomically |
| `GET` | `/v2/status` | Peer role, sequence number and lag |
| `GET` | `/v2/keyspaces` | List keyspaces and their settings |
## Reading a Key
```http
GET /v2/keyspaces/sessions/keys/dXNlcjo0Mg== HTTP/1.1
Accept: application/json
X-Quill-Consistency: leader
```
```json
{
"key": "dXNlcjo0Mg==",
"value": "eyJuYW1lIjogIkFkYSJ9",
"sequence": 918273,
"expires_at": "2026-12-02T10:00:00Z"
}
```
A missing key returns `404` with the error code `KeyNotFound`. The consistency header is optional and defaults to `leader`.
## Writing Several Keys Atomically
A transaction applies all of its operations or no- ▲ warning Starts in the middle of a word.
- ▲ warning Ends inside a table: the table continues in the next chunk.
eader is optional and defaults to `leader`.
## Writing Several Keys Atomically
A transaction applies all of its operations or none of them. Operations are applied in order, and a `check` operation fails the whole transaction if a key does not have the expected sequence number, which is how you implement compare-and-set.
```json
{
"operations": [
{"op": "check", "keyspace": "config", "key": "ZmVhdHVyZXM=", "sequence": 41},
{"op": "put", "keyspace": "config", "key": "ZmVhdHVyZXM=", "value": "eyJkYXJrIjogdHJ1ZX0="},
{"op": "delete", "keyspace": "sessions", "key": "dXNlcjo0Mw=="}
]
}
```
## Error Codes
| Status | Code | Meaning | Retry? |
|---|---|---|---|
| `400` | `BadRequest` | The request body or a parameter is invalid | No |
| `404` | `KeyNotFound`- ✕ error 150 words, over the limit of 120. Embedding models truncate the rest.
- ▲ warning Starts in the middle of a word.
- ▲ warning Ends in the middle of a word.
ng | Retry? | |---|---|---|---| | `400` | `BadRequest` | The request body or a parameter is invalid | No | | `404` | `KeyNotFound` | The key does not exist or has expired | No | | `409` | `CheckFailed` | A `check` operation did not match | After re-reading | | `413` | `BatchTooLarge` | The transaction exceeds `max_batch_bytes` | No; split it | | `423` | `ReadOnly` | The group has lost quorum | Yes, with backoff | | `500` | `CorruptBlock` | A checksum failed while reading | No; see the runbook | | `503` | `NoLeader` | An election is in progress | Yes, after 1–3 s | | `504` | `Timeout` | The request exceeded `read_timeout` | Yes | ## Pagination Scans return at most `limit` keys (default 1000) and a `next` cursor when more keys remain. Pass the cursor back unchanged to c
- ▲ warning Starts in the middle of a word.
n Scans return at most `limit` keys (default 1000) and a `next` cursor when more keys remain. Pass the cursor back unchanged to continue. Cursors are tied to a snapshot and expire after five minutes; an expired cursor returns `400` with the code `CursorExpired`. ## Authentication The HTTP API supports bearer tokens. Set `http_tokens_file` to a file with one token per line; requests without a valid `Authorization: Bearer` header receive `401`. Tokens are compared in constant time and never logged. For anything beyond a trusted network, put the API behind a TLS-terminating proxy.
| Severity | Where | Check | Message |
|---|---|---|---|
| ✕ error | #3 | over_limit | 150 words, over the limit of 120. Embedding models truncate the rest. |
| ▲ warning | #0 | ends_in_table | Ends inside a table: the table continues in the next chunk. |
| ▲ warning | #1 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #1 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #2 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #2 | ends_in_table | Ends inside a table: the table continues in the next chunk. |
| ▲ warning | #3 | starts_mid_word | Starts in the middle of a word. |
| ▲ warning | #3 | ends_mid_word | Ends in the middle of a word. |
| ▲ warning | #4 | starts_mid_word | Starts in the middle of a word. |
The same document in every run, on the same scale. Click a bar to open that chunk.
07 · Release Notes fixed-size · 780 chars, 130 overlap
- ✕ error 125 words, over the limit of 120. Embedding models truncate the rest.
# Release Notes > Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software. ## 2.4.0 - Tiered compaction now runs on a separate thread pool, so it no longer delays leveled compaction in other keyspaces. - New `quill move-blobs` command moves blob files to another volume without downtime. - Fixed a rare case where a cursor could skip keys written during a scan. ## 2.3.0 - Added the `bounded` consistency level. - `quill backup` is incremental by default. - The HTTP API returns `X-Quill-Sequence` on every response. ## 2.2.0 - Added bearer-token authentication to the HTTP API. - Bloom filters use 10 bits per key by default, down from 12, saving memory with little effect on reads.
- ▲ warning Starts in the middle of a word.
I. - Bloom filters use 10 bits per key by default, down from 12, saving memory with little effect on reads.
The same document in every run, on the same scale. Click a bar to open that chunk.
01 · Quillstore Overview blank-line blocks
1 chunk(s) could not be placed in the source: #5.
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
# Quillstore Overview
> Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software.
- ▲ warning Only 4 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## What Quillstore Is
Quillstore is an embedded, persistent key-value store for services that need fast local reads and durable writes without running a separate database server. It links into your application as a library, stores data in a single directory, and can optionally replicate that directory to two or more peers.
Quillstore is designed for three workloads: session and cache data that must survive restarts, event logs that are written once and read in order, and configuration snapshots that change rarely but must be identical on every node.
- ✕ error Empty chunk: it has no text to embed.
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Core Concepts
- ▲ warning Only 2 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
### Keyspaces
A keyspace is a named collection of keys with its own settings. Each keyspace chooses a compaction strategy, a compression codec and a retention policy. Keys are byte strings of up to 4 KiB; values can be up to 64 MiB, although values above 1 MiB are stored out of line in blob files.
- ▲ warning Only 4 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
### Records and Versions
Every write creates a new version of a record. A version carries a 64-bit sequence number assigned by the writer, a timestamp, and an optional time-to-live. Readers see the latest version unless they open a snapshot, which pins the sequence number at the moment it was created.
- ▲ warning Only 4 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
### The Write-Ahead Log
Before a write is acknowledged, it is appended to the write-ahead log (WAL) and, depending on the durability level, flushed to disk. The WAL is the only structure that must be written synchronously; everything else is rebuilt from it after a crash.
- ▲ warning Only 2 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
### Segments
Data on disk lives in immutable segment files. A segment holds sorted keys, a sparse index and a Bloom filter. Segments are merged in the background by compaction, which discards overwritten and expired versions.
- ▲ warning Only 5 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Architecture at a Glance
A Quillstore node has four layers. The table below lists them from the application down to the disk.
| Layer | Responsibility | Main settings | |---|---|---| | API | Get, put, delete, scan, transactions | `max_batch_bytes`, `read_timeout` | | Memtable | In-memory sorted buffer for recent writes | `memtable_size`, `memtable_count` | | Storage engine | WAL, segments, compaction, blob files | `durability`, `compaction`, `codec` | | Replication | Log shipping to peers, leader election | `peers`, `quorum`, `election_timeout` |
Each layer can be tuned independently, but the defaults are chosen to work well together for small and medium datasets of up to a few hundred gigabytes per node.
- ▲ warning Only 6 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## When Not to Use Quillstore
Quillstore is not a relational database. It has no query planner, no joins and no secondary indexes beyond what you build yourself with additional keyspaces. It is also not designed for datasets that do not fit on one machine: replication copies the whole dataset to every peer instead of sharding it.
If you need ad-hoc queries across many fields, or a dataset that grows beyond a single node's disk, use a dedicated database server instead.
- ▲ warning Only 2 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Glossary
- ✕ error 132 words, over the limit of 120. Embedding models truncate the rest.
| Term | Meaning | |---|---| | Blob file | A file holding large values outside the segments | | Compaction | Background merging of segments to reclaim space | | Durability level | How far a write must travel before it is acknowledged | | Leader | The peer that accepts writes in a replicated group | | Memtable | The in-memory buffer of recent writes | | Quorum | The number of peers that must confirm a replicated write | | Segment | An immutable sorted file of keys and values | | Snapshot | A consistent read view pinned to one sequence number | | Tombstone | A marker that records the deletion of a key | | WAL | Write-ahead log, the append-only record of every write |
| Severity | Where | Check | Message |
|---|---|---|---|
| ✕ error | #5 | empty | Empty chunk: it has no text to embed. |
| ✕ error | #23 | over_limit | 132 words, over the limit of 120. Embedding models truncate the rest. |
| ▲ warning | #0 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #0 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #2 | under_limit | Only 4 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #2 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #6 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #6 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #7 | under_limit | Only 2 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #7 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #9 | under_limit | Only 4 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #9 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #11 | under_limit | Only 4 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #11 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #13 | under_limit | Only 2 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #13 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #15 | under_limit | Only 5 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #15 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #19 | under_limit | Only 6 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #19 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #22 | under_limit | Only 2 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #22 | heading_only | Contains only a heading: its content ended up in another chunk. |
The same document in every run, on the same scale. Click a bar to open that chunk.
02 · Installation and Configuration blank-line blocks
- ▲ warning Only 4 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
# Installation and Configuration
> Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software.
- ▲ warning Only 2 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Requirements
Quillstore runs on 64-bit Linux and macOS. It needs a filesystem that supports `fsync` on directories, which rules out some network filesystems. For production, use a local SSD and reserve at least twice the size of your dataset, because compaction temporarily needs room for both the old and the new segments.
- ▲ warning Only 4 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Installing the Library
The library is published for Python, Go and Rust. Pick the package for your language:
```bash pip install quillstore # Python 3.10 or newer go get example.org/quillstore/v2 # Go 1.22 or newer cargo add quillstore # Rust 2021 edition ```
The command-line tool, `quill`, is installed with the Python package. It is used for inspection, backups and recovery and never needs to run while your application is running.
- ▲ warning Only 4 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Opening a Store
A store is opened on a directory. If the directory is empty, Quillstore creates the files it needs.
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Cuts a code block: the opening or closing ``` fence is in another chunk.
```python import quillstore
- ▲ warning Only 7 words, under the minimum of 8. Tiny chunks carry little meaning.
store = quillstore.open(
"/var/lib/myapp/store",
durability="fsync",
memtable_size="64MiB",
)with store.transaction() as tx:
tx.put(b"user:42", b'{"name": "Ada"}')
tx.put(b"user:43", b'{"name": "Grace"}')- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Cuts a code block: the opening or closing ``` fence is in another chunk.
print(store.get(b"user:42")) store.close() ```
Always close the store before the process exits. Closing flushes the memtable and writes a clean-shutdown marker, which makes the next start faster because the WAL does not need to be replayed.
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Configuration File
Instead of passing options in code, you can keep them in a `quillstore.toml` file next to the data directory. Options passed in code override the file.
- ▲ warning Cuts a code block: the opening or closing ``` fence is in another chunk.
```toml [store] durability = "fsync" memtable_size = "64MiB" memtable_count = 2
[keyspace.sessions] compaction = "tiered" codec = "lz4" ttl = "24h"
- ▲ warning Cuts a code block: the opening or closing ``` fence is in another chunk.
[keyspace.events] compaction = "leveled" codec = "zstd" retention = "30d" ```
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Configuration Reference
The table below lists every store-level option, its default and when to change it.
- ▲ warning Ends inside a table: the table continues in the next chunk.
| Option | Default | Description | |---|---|---| | `durability` | `fsync` | `none`, `flush` or `fsync`; see the storage engine guide | | `memtable_size` | `32MiB` | Size at which a memtable is frozen and written to a segment | | `memtable_count` | `2` | Number of memtables kept in memory, including frozen ones | | `max_batch_bytes` | `4MiB` | Largest batch a single transaction may write | | `read_timeout` | `2s` | Time a read waits for a lock before failing | | `compaction_threads` | `2` | Background threads used for compaction |
- ▲ warning Starts inside a table: these rows are separated from the table header.
| `blob_threshold` | `1MiB` | Values above this size are stored in blob files | | `codec` | `lz4` | Default compression: `none`, `lz4` or `zstd` | | `bloom_bits_per_key` | `10` | Bloom filter size; higher means fewer false positives | | `cache_size` | `256MiB` | Block cache shared by all keyspaces | | `max_open_files` | `1000` | Segment files kept open at the same time | | `checksum` | `crc32c` | Checksum used for WAL entries and segment blocks | | `peers` | empty | Addresses of replication peers | | `quorum` | `majority` | Peers that must confirm a replicated write | | `election_timeout` | `1500ms` | Time without a heartbeat before peers elect a new leader |
Most applications only change `durability`, `memtable_size` and `cache_size`. The others exist for unusual workloads and are safe to leave at their defaults.
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Environment Variables
Two environment variables are read at startup. `QUILL_LOG` sets the log level (`error`, `warn`, `info` or `debug`), and `QUILL_CONFIG` points to a configuration file in a different location. Environment variables never override options passed in code.
- ▲ warning Only 2 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Upgrading
Quillstore reads data written by the previous two minor versions. To upgrade across more versions, upgrade one step at a time and open the store once at each step, which converts the segment format. Never downgrade a store that has been opened by a newer version: older versions refuse to open it, to prevent silent data loss.
| Severity | Where | Check | Message |
|---|---|---|---|
| ▲ warning | #0 | under_limit | Only 4 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #0 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #2 | under_limit | Only 2 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #2 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #4 | under_limit | Only 4 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #4 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #8 | under_limit | Only 4 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #8 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #10 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #10 | split_code_block | Cuts a code block: the opening or closing ``` fence is in another chunk. |
| ▲ warning | #11 | under_limit | Only 7 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #13 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #13 | split_code_block | Cuts a code block: the opening or closing ``` fence is in another chunk. |
| ▲ warning | #15 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #15 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #17 | split_code_block | Cuts a code block: the opening or closing ``` fence is in another chunk. |
| ▲ warning | #19 | split_code_block | Cuts a code block: the opening or closing ``` fence is in another chunk. |
| ▲ warning | #20 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #20 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #22 | ends_in_table | Ends inside a table: the table continues in the next chunk. |
| ▲ warning | #23 | starts_in_table | Starts inside a table: these rows are separated from the table header. |
| ▲ warning | #25 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #25 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #27 | under_limit | Only 2 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #27 | heading_only | Contains only a heading: its content ended up in another chunk. |
The same document in every run, on the same scale. Click a bar to open that chunk.
03 · Storage Engine blank-line blocks
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
# Storage Engine
> Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software.
- ▲ warning Only 4 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## The Write Path
A write travels through three stages before it becomes part of a segment. First, it is appended to the write-ahead log. Second, it is inserted into the active memtable, a sorted in-memory structure. Third, when the memtable reaches `memtable_size`, it is frozen and written to disk as a new segment by a background thread, after which the matching part of the WAL can be deleted.
The application only waits for the first two stages. The third happens in the background, which is why writes stay fast even while large segments are being written.
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Durability Levels
The durability level decides how far a write must travel before Quillstore acknowledges it. Choosing a level is a trade-off between speed and the amount of data you can lose in a crash.
| Level | Acknowledged after | Data lost on process crash | Data lost on power loss | |---|---|---|---| | `none` | Insert into memtable | Up to one memtable | Up to one memtable | | `flush` | Write to the OS page cache | Nothing | Up to a few seconds | | `fsync` | `fsync` of the WAL file | Nothing | Nothing |
With `fsync`, Quillstore groups concurrent writes into one `fsync` call, so the cost per write falls as the number of writers grows. A single writer on a typical SSD reaches a few thousand durable writes per second; sixteen writers reach several times that.
- ▲ warning Only 4 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## The Read Path
A read checks the active memtable, then the frozen memtables, then the segments from newest to oldest. It stops at the first version it finds. Each segment has a Bloom filter, so most segments that do not contain the key are skipped without reading from disk.
Range scans merge all of these sources at once. They are efficient when the range is narrow or when compaction keeps the number of overlapping segments small.
- ▲ warning Only 2 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Compaction
Segments are immutable, so overwritten and deleted keys keep taking space until compaction merges segments and drops the old versions. Quillstore offers two strategies, chosen per keyspace.
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
### Leveled Compaction
Leveled compaction organizes segments into levels, each ten times larger than the previous one. Within a level, segments do not overlap, so a read touches at most one segment per level. The cost is higher write amplification: a key may be rewritten once per level as it moves down.
Use leveled compaction for read-heavy keyspaces and for keyspaces where keys are overwritten often.
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
### Tiered Compaction
Tiered compaction waits until several segments of similar size exist and merges them together. It writes each key fewer times, so it is cheaper for write-heavy workloads, but reads may have to check more segments and temporary disk usage is higher.
Use tiered compaction for append-heavy keyspaces such as event logs and for data with a short time-to-live.
- ▲ warning Only 4 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
### Comparing the Strategies
| Property | Leveled | Tiered | |---|---|---| | Write amplification | High (10–30×) | Low (3–6×) | | Read amplification | Low | Medium | | Space amplification | About 1.1× | Up to 2× | | Best for | Reads, updates | Appends, expiring data | | Default for | `sessions`, `config` | `events`, `metrics` |
- ▲ warning Only 4 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Tombstones and Expiry
Deleting a key writes a tombstone, a small marker that hides older versions. Tombstones are removed by compaction once no older version of the key remains in any segment. Keys with a time-to-live expire the same way: they become invisible to readers at expiry and are physically removed during the next compaction that touches them.
A keyspace with many deletes and little compaction can accumulate tombstones and slow down range scans. The `quill stats` command reports the tombstone ratio for each keyspace; above 30 %, consider a manual compaction.
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Blob Files
Values larger than `blob_threshold` are written to separate blob files, and the segment stores only a pointer. This keeps segments small and makes compaction cheaper, because large values are not rewritten when their keys move between levels. Blob files are garbage-collected when the share of unreferenced values in a file exceeds 50 %.
- ▲ warning Only 4 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Checksums and Corruption
Every WAL entry and every segment block carries a checksum. A mismatch on read fails the read with a `CorruptBlock` error instead of returning damaged data. The store keeps running, and the error message names the segment file, so you can restore that file from a replica or a backup.
The following script verifies every segment of a store offline and prints the files that need attention:
- ▲ warning Cuts a code block: the opening or closing ``` fence is in another chunk.
```bash
#!/usr/bin/env bash
# Verify every segment of a stopped store and list damaged files.
set -euo pipefail
STORE_DIR=${1:?usage: verify.sh STORE_DIR}quill verify --store "$STORE_DIR" --format json > /tmp/verify.json damaged=$(jq -r '.segments[] | select(.status != "ok") | .file' /tmp/verify.json)
if [ -z "$damaged" ]; then echo "All segments are healthy." exit 0 fi
- ▲ warning Cuts a code block: the opening or closing ``` fence is in another chunk.
echo "Damaged segments:" for file in $damaged; do size=$(stat -c %s "$STORE_DIR/$file" 2>/dev/null || stat -f %z "$STORE_DIR/$file") echo " $file ($size bytes)" done echo "Restore these files from a replica: quill restore-segment --from PEER FILE" exit 1 ```
Run the script while the store is closed. Verifying a store that is being written to may report segments that are still being created as incomplete.
| Severity | Where | Check | Message |
|---|---|---|---|
| ▲ warning | #0 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #0 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #2 | under_limit | Only 4 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #2 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #5 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #5 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #9 | under_limit | Only 4 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #9 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #12 | under_limit | Only 2 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #12 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #14 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #14 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #17 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #17 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #20 | under_limit | Only 4 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #20 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #22 | under_limit | Only 4 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #22 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #25 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #25 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #27 | under_limit | Only 4 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #27 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #30 | split_code_block | Cuts a code block: the opening or closing ``` fence is in another chunk. |
| ▲ warning | #33 | split_code_block | Cuts a code block: the opening or closing ``` fence is in another chunk. |
The same document in every run, on the same scale. Click a bar to open that chunk.
04 · Replication blank-line blocks
- ▲ warning Only 2 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
# Replication
> Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software.
- ▲ warning Only 4 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## How Replication Works
A replicated Quillstore group has one leader and one or more followers. Only the leader accepts writes. It appends each write to its WAL and ships the new WAL entries to every follower, which append them to their own WAL and apply them to their memtable. A write is acknowledged once a quorum of peers, including the leader, has stored it according to the durability level.
Followers can serve reads. Those reads may be slightly behind the leader; see the consistency levels below.
- ▲ warning Only 5 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Setting Up a Group
Every peer lists all peers, including itself, in the `peers` option. The order does not matter.
```toml [store] peers = ["10.0.0.11:7400", "10.0.0.12:7400", "10.0.0.13:7400"] quorum = "majority" election_timeout = "1500ms" ```
Start the peers in any order. When a majority can reach each other, they elect a leader, and the group starts accepting writes. A group of three tolerates one failed peer; a group of five tolerates two.
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Leader Election
Peers exchange heartbeats every `election_timeout / 5`. When a follower misses heartbeats for a full `election_timeout`, it becomes a candidate and asks the others for votes. A peer votes for a candidate only if the candidate's log is at least as complete as its own, which guarantees that a new leader never loses acknowledged writes.
During an election, writes fail with `NoLeader` and should be retried. Elections usually finish within two election timeouts.
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Consistency Levels
Reads accept a consistency level that trades freshness for latency.
| Level | Served by | Guarantee | Typical latency | |---|---|---|---| | `local` | Any peer | May return stale data | Lowest | | `bounded` | Any peer | At most `max_lag` behind the leader | Low | | `leader` | The leader | Sees all acknowledged writes | Medium | | `linearizable` | The leader, after a quorum check | Sees all writes acknowledged before the read started | Highest |
Use `leader` by default. Use `local` for caches and dashboards that tolerate stale data, and `linearizable` only for reads that must observe a write made by another client a moment earlier.
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Failure Modes
The table below lists the failures a group handles automatically and those that need an operator.
- ✕ error 156 words, over the limit of 120. Embedding models truncate the rest.
| Failure | Detected by | Automatic response | Operator action | |---|---|---|---| | Follower crash | Missing heartbeat replies | Leader keeps serving with remaining quorum | Restart the follower; it catches up from the leader | | Leader crash | Followers miss heartbeats | New leader elected | Restart the old leader; it rejoins as a follower | | Network partition | Missing heartbeats on both sides | Minority side stops accepting writes | Fix the network; the minority catches up | | Slow disk on a follower | Growing replication lag | Leader throttles shipping to that follower | Replace the disk or remove the peer | | Disk failure | `CorruptBlock` or I/O errors | Peer stops and reports the failed path | Follow the node recovery runbook | | Lost quorum | No leader can be elected | Group becomes read-only | Restore failed peers or force a new configuration |
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Changing Membership
Peers are added and removed one at a time with `quill peers add` and `quill peers remove`. Each change is itself replicated, so it only takes effect once a quorum has stored it. Never edit the `peers` option of a running group by hand: peers with different lists can elect two leaders.
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Replication Lag
The leader tracks how far behind each follower is, in WAL entries and in bytes. `quill status` shows the lag for each peer. A lag that keeps growing means the follower cannot keep up, usually because of a slow disk or a saturated network link. Short spikes during compaction are normal.
| Severity | Where | Check | Message |
|---|---|---|---|
| ✕ error | #18 | over_limit | 156 words, over the limit of 120. Embedding models truncate the rest. |
| ▲ warning | #0 | under_limit | Only 2 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #0 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #2 | under_limit | Only 4 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #2 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #5 | under_limit | Only 5 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #5 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #9 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #9 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #12 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #12 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #16 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #16 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #19 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #19 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #21 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #21 | heading_only | Contains only a heading: its content ended up in another chunk. |
The same document in every run, on the same scale. Click a bar to open that chunk.
05 · Operations Runbook blank-line blocks
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
# Operations Runbook
> Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software.
- ▲ warning Only 4 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Before You Start
> **Warning:** commands in this runbook change data on disk. Run them on one peer at a time, and only after taking a backup or confirming that the other peers are healthy.
Each procedure lists its symptoms, the checks to run, and the steps to fix the problem. Run the checks first: several symptoms look alike but need different fixes.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Recovering a Node After a Disk Failure
- ▲ warning Only 2 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
### Symptoms
The peer stops and logs `I/O error` or `CorruptBlock` with a file path. `quill status` on another peer shows it as unreachable, and the group keeps serving writes if a quorum remains.
- ▲ warning Only 2 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
### Checks
1. Confirm that the remaining peers still form a quorum: `quill status --peer 10.0.0.12:7400`. 2. Check the kernel log of the failed machine for disk errors: `dmesg | grep -i error`. 3. If the disk is still readable, run the verification script from the storage engine guide to list damaged segments.
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
### Recovery Steps
If only a few segments are damaged and the disk is healthy, restore those segments from a peer:
```bash quill restore-segment --from 10.0.0.12:7400 --store /var/lib/myapp/store 000123.seg quill verify --store /var/lib/myapp/store ```
If the disk has failed, replace it and rebuild the peer from scratch:
```bash # On the new, empty disk mkdir -p /var/lib/myapp/store quill bootstrap --from 10.0.0.12:7400 --store /var/lib/myapp/store systemctl start myapp ```
`quill bootstrap` copies the newest segments from a healthy peer and then replays the WAL entries written since. For a 200 GB store on a 1 Gbit/s link, expect about 30 minutes. The peer rejoins the group automatically when it has caught up.
- ℹ info Same text as chunk #3: it will be embedded and retrieved twice.
> **Warning:** commands in this runbook change data on disk. Run them on one peer at a time, and only after taking a backup or confirming that the other peers are healthy.
- ▲ warning Only 2 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Backups
- ▲ warning Only 4 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
### Taking a Backup
`quill backup` creates a consistent copy of a running store without stopping it. It opens a snapshot, copies the segments it references and the WAL up to the snapshot's sequence number, and writes a manifest.
```bash quill backup --store /var/lib/myapp/store --to /backups/store-$(date +%F) ```
Backups are incremental by default: segments already present in the previous backup are hard-linked instead of copied.
- ▲ warning Only 4 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
### Restoring a Backup
Restoring replaces the whole store. Stop the application, move the current directory aside, and restore:
```bash systemctl stop myapp mv /var/lib/myapp/store /var/lib/myapp/store.old quill restore --from /backups/store-2026-11-30 --to /var/lib/myapp/store systemctl start myapp ```
In a replicated group, restore a backup on one peer only, then rebuild the other peers from it with `quill bootstrap`.
- ▲ warning Only 2 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Monitoring
Quillstore exposes metrics on `/metrics` when `metrics_port` is set. The most useful ones are listed below.
| Metric | Meaning | Alert when | |---|---|---| | `quill_write_latency_seconds` | Time to acknowledge a write | p99 above 50 ms for 10 minutes | | `quill_read_latency_seconds` | Time to serve a read | p99 above 20 ms for 10 minutes | | `quill_compaction_pending_bytes` | Data waiting to be compacted | Growing for more than an hour | | `quill_tombstone_ratio` | Share of tombstones in scanned data | Above 0.3 | | `quill_replication_lag_entries` | WAL entries a follower is behind | Above 100 000 for 5 minutes | | `quill_disk_free_bytes` | Free space on the data volume | Below twice the dataset size | | `quill_corrupt_blocks_total` | Checksum failures since start | Any increase |
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Slow Writes
When write latency rises, check the compaction backlog first. If `quill_compaction_pending_bytes` keeps growing, compaction cannot keep up with the write rate: add compaction threads, move write-heavy keyspaces to tiered compaction, or reduce the write rate. If the backlog is stable, check the disk with `iostat -x 5` for saturation.
- ▲ warning Only 6 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Running Out of Disk Space
Compaction needs free space to write new segments before deleting old ones. When free space falls below the size of the largest compaction, Quillstore stops compacting and logs `compaction paused: disk full`. Free space by lowering retention on large keyspaces, deleting old backups from the same volume, or moving blob files to another disk with `quill move-blobs`.
| Severity | Where | Check | Message |
|---|---|---|---|
| ▲ warning | #0 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #0 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #2 | under_limit | Only 4 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #2 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #5 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #6 | under_limit | Only 2 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #6 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #8 | under_limit | Only 2 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #8 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #10 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #10 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #17 | under_limit | Only 2 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #17 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #18 | under_limit | Only 4 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #18 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #22 | under_limit | Only 4 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #22 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #26 | under_limit | Only 2 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #26 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #29 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #29 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #31 | under_limit | Only 6 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #31 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ℹ info | #16 | duplicate | Same text as chunk #3: it will be embedded and retrieved twice. |
The same document in every run, on the same scale. Click a bar to open that chunk.
06 · HTTP API Reference blank-line blocks
- ▲ warning Only 4 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
# HTTP API Reference
> Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software.
- ▲ warning Only 2 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Overview
The optional HTTP API lets other processes read and write a store. Enable it with `http_port`. All requests and responses use JSON, keys and values are base64-encoded, and every response carries the store's current sequence number in the `X-Quill-Sequence` header.
- ▲ warning Only 2 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Endpoints
| Method | Path | Description |
|---|---|---|
| `GET` | `/v2/keyspaces/{ks}/keys/{key}` | Read the latest version of a key |
| `PUT` | `/v2/keyspaces/{ks}/keys/{key}` | Write a value |
| `DELETE` | `/v2/keyspaces/{ks}/keys/{key}` | Delete a key |
| `POST` | `/v2/keyspaces/{ks}/scan` | Read a range of keys |
| `POST` | `/v2/transactions` | Apply several writes atomically |
| `GET` | `/v2/status` | Peer role, sequence number and lag |
| `GET` | `/v2/keyspaces` | List keyspaces and their settings |- ▲ warning Only 4 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Reading a Key
```http GET /v2/keyspaces/sessions/keys/dXNlcjo0Mg== HTTP/1.1 Accept: application/json X-Quill-Consistency: leader ```
```json
{
"key": "dXNlcjo0Mg==",
"value": "eyJuYW1lIjogIkFkYSJ9",
"sequence": 918273,
"expires_at": "2026-12-02T10:00:00Z"
}
```A missing key returns `404` with the error code `KeyNotFound`. The consistency header is optional and defaults to `leader`.
- ▲ warning Only 5 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Writing Several Keys Atomically
A transaction applies all of its operations or none of them. Operations are applied in order, and a `check` operation fails the whole transaction if a key does not have the expected sequence number, which is how you implement compare-and-set.
```json
{
"operations": [
{"op": "check", "keyspace": "config", "key": "ZmVhdHVyZXM=", "sequence": 41},
{"op": "put", "keyspace": "config", "key": "ZmVhdHVyZXM=", "value": "eyJkYXJrIjogdHJ1ZX0="},
{"op": "delete", "keyspace": "sessions", "key": "dXNlcjo0Mw=="}
]
}
```- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Error Codes
- ✕ error 130 words, over the limit of 120. Embedding models truncate the rest.
| Status | Code | Meaning | Retry? | |---|---|---|---| | `400` | `BadRequest` | The request body or a parameter is invalid | No | | `404` | `KeyNotFound` | The key does not exist or has expired | No | | `409` | `CheckFailed` | A `check` operation did not match | After re-reading | | `413` | `BatchTooLarge` | The transaction exceeds `max_batch_bytes` | No; split it | | `423` | `ReadOnly` | The group has lost quorum | Yes, with backoff | | `500` | `CorruptBlock` | A checksum failed while reading | No; see the runbook | | `503` | `NoLeader` | An election is in progress | Yes, after 1–3 s | | `504` | `Timeout` | The request exceeded `read_timeout` | Yes |
- ▲ warning Only 2 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Pagination
Scans return at most `limit` keys (default 1000) and a `next` cursor when more keys remain. Pass the cursor back unchanged to continue. Cursors are tied to a snapshot and expire after five minutes; an expired cursor returns `400` with the code `CursorExpired`.
- ▲ warning Only 2 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## Authentication
The HTTP API supports bearer tokens. Set `http_tokens_file` to a file with one token per line; requests without a valid `Authorization: Bearer` header receive `401`. Tokens are compared in constant time and never logged. For anything beyond a trusted network, put the API behind a TLS-terminating proxy.
| Severity | Where | Check | Message |
|---|---|---|---|
| ✕ error | #14 | over_limit | 130 words, over the limit of 120. Embedding models truncate the rest. |
| ▲ warning | #0 | under_limit | Only 4 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #0 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #2 | under_limit | Only 2 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #2 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #4 | under_limit | Only 2 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #4 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #6 | under_limit | Only 4 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #6 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #10 | under_limit | Only 5 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #10 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #13 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #13 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #15 | under_limit | Only 2 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #15 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #17 | under_limit | Only 2 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #17 | heading_only | Contains only a heading: its content ended up in another chunk. |
The same document in every run, on the same scale. Click a bar to open that chunk.
07 · Release Notes blank-line blocks
- ▲ warning Only 3 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
# Release Notes
> Quillstore is a fictional product. This documentation was written to demonstrate chunkscope and describes no real software.
- ▲ warning Only 2 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## 2.4.0
- Tiered compaction now runs on a separate thread pool, so it no longer delays leveled compaction in other keyspaces. - New `quill move-blobs` command moves blob files to another volume without downtime. - Fixed a rare case where a cursor could skip keys written during a scan.
- ▲ warning Only 2 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## 2.3.0
- Added the `bounded` consistency level. - `quill backup` is incremental by default. - The HTTP API returns `X-Quill-Sequence` on every response.
- ▲ warning Only 2 words, under the minimum of 8. Tiny chunks carry little meaning.
- ▲ warning Contains only a heading: its content ended up in another chunk.
## 2.2.0
- Added bearer-token authentication to the HTTP API. - Bloom filters use 10 bits per key by default, down from 12, saving memory with little effect on reads.
| Severity | Where | Check | Message |
|---|---|---|---|
| ▲ warning | #0 | under_limit | Only 3 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #0 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #2 | under_limit | Only 2 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #2 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #4 | under_limit | Only 2 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #4 | heading_only | Contains only a heading: its content ended up in another chunk. |
| ▲ warning | #6 | under_limit | Only 2 words, under the minimum of 8. Tiny chunks carry little meaning. |
| ▲ warning | #6 | heading_only | Contains only a heading: its content ended up in another chunk. |
The same document in every run, on the same scale. Click a bar to open that chunk.