Diffinery

homeflare/celldpublic

celld/crates/ltx/README.md
61 lines · 3.1 KBRaw History
1# celld-ltx
2
3`celld-ltx` is celld's in-process SQLite replication library. It captures
4committed WAL data as L0 LTX segments and reports the captured position. The
5crate can write segments to a filesystem or an object store. It can restore a
6database, compact levels, create a snapshot, and read segments from bundle
7objects.
8
9celld uses this library inside a larger durability protocol. The output gate,
10epoch fencing, replicated node log, and takeover recovery enforce the write
11acknowledgement contract.
12
13## Provenance and attribution
14
15Seeded on 2026-08-03 from a read-only snapshot of rustyriver
16(https://github.com/mikenomitch/rustyriver), a from-scratch Rust
17reimplementation of Litestream v0.5 and the LTX file format. celld owns and
18evolves this snapshot as first-class celld source; it does not track an
19upstream branch.
20
21Attribution for the vendored and ported work:
22
23- **rustyriver** — Copyright 2026 The rustyriver authors, licensed under the
24 Apache License, Version 2.0.
25- **Litestream** (https://github.com/benbjohnson/litestream) — Copyright (c)
26 Ben Johnson and the Litestream authors, licensed under the Apache License,
27 Version 2.0. The original replication behavior comes from tag v0.5.11. The
28 current block format follows tag v0.5.16 because it includes LTX v0.5.2.
29- **LTX file format and reference implementation**
30 (https://github.com/superfly/ltx), tag v0.5.2 — Copyright (c) Superfly, Inc.,
31 licensed under the Apache License, Version 2.0.
32- **pierrec/lz4 block compressor**
33 (https://github.com/pierrec/lz4), tag v4.1.23 — Copyright (c) 2015 Pierre
34 Curto, licensed under the BSD 3-Clause License. The Rust port preserves the
35 exact compressed bytes that the LTX v0.5.2 writer produces.
36
37The port is not complete, deliberately. `leaser.rs` — Litestream's
38object-storage lease (`leaser.go`, `heartbeat.go`, `s3/leaser.go`) — was
39ported and then removed on 2026-08-06, unused. celld fences cell ownership
40with a conditional-write record carrying an epoch, and fences the data path by
41stamping that epoch into the LTX prefix; a lease file under the replica prefix
42would be a second, competing layer. Upstream's own leaser is unwired for the
43same reason. Recover it from git if a future design needs it.
44
45The full Apache License, Version 2.0 text is in [LICENSE](LICENSE). The full
46BSD 3-Clause License text is in
47[LICENSE.pierrec-lz4](LICENSE.pierrec-lz4).
48
49## File compatibility
50
51Celld and Litestream v0.5.16 can read the new block files and the older frame
52files. Litestream v0.5.11 can read only the older frame files. This is a reader
53compatibility boundary because LTX keeps file version 3 for both layouts.
54
55The ordinary celld L0 writer still emits the older frame representation. The
56v0.5.2 encoder and compactor emit exact block files. Celld contains a
57node-wide scheduler that publishes additive L1 files, and the scheduler is on
58by default. Every takeover target must have the dual decoder before the first
59L1 publication, so a mixed fleet must set `CELLD_LTX_COMPACTION=0` until all
60nodes can read block files. The same reader-first requirement applies to a
61later L0 writer switch.