Skip to content

feat: experimental Turso Database engine backend (litewire-turso) - #9

Merged
luthermonson merged 3 commits into
mainfrom
feat/turso-backend
Jul 15, 2026
Merged

feat: experimental Turso Database engine backend (litewire-turso)#9
luthermonson merged 3 commits into
mainfrom
feat/turso-backend

Conversation

@luthermonson

Copy link
Copy Markdown
Contributor

Summary

Phase 1 of the ePHPm Turso-engine roadmap: an experimental backend implementing Backend/BackendConn over Turso Database, the Rust rewrite of SQLite.

  • New crate crates/litewire-turso, engine pinned exactly at turso = "=0.7.0" (first non-pre release of the 0.7 line; Beta upstream — bump deliberately, never via cargo update).
  • Facade feature turso, off by default; re-exports litewire_turso and Turso.
  • Async-native (no spawn_blocking hop); per-session tokio::sync::Mutex mirrors the rusqlite backend's session semantics. One turso::Database factory, one turso::Connection per wire session (per-conn transaction isolation).
  • Session parity with the rusqlite backend: busy_timeout 5000 ms and PRAGMA synchronous = NORMAL (the engine's own default is FULL — a 40x concurrent-write throughput difference, see the harness).
  • Busy errors tagged with SQLite phrasing so the mysql/postgres error_map classifiers emit retryable lock-wait codes.
  • Known-unsupported, documented in crate docs: VACUUM (rejected with a clear error), multi-process access, ATTACH/DETACH, non-UTF-8 TEXT round-trips.
  • examples/phase1_gates.rs: reproducible gate harness (latency matrix, N-writer concurrency, SQLite<->Turso file-format round-trip, kill -9 crash smoke). Results recorded in ePHPm's docs/turso-phase1-results.md (companion PR).

Consumed by ephpm's feat/db-engine-turso-experimental branch (opt-in [db.sqlite] engine = "turso" knob). Default backend everywhere remains rusqlite.

Test plan

  • cargo test -p litewire-turso — 17 unit tests mirroring the rusqlite backend suite (CRUD, types, isolation, concurrency) + 2 litewire-level integration tests
  • cargo test --workspace green
  • cargo clippy --workspace --all-targets -- -D warnings green (turso feature checked separately: cargo check -p litewire --features turso)
  • Gate harness run on Linux: round-trip checksums MATCH both directions, crash smoke 10/10 clean

…urso)

New crate crates/litewire-turso implementing Backend/BackendConn over the
Turso Database engine (the Rust rewrite of SQLite), pinned exactly at
turso =0.7.0 (first non-pre release of the 0.7 line, Beta upstream).

- Async-native: no spawn_blocking hop; per-session tokio Mutex mirrors the
  rusqlite backend's one-statement-at-a-time session semantics.
- Per-connection isolation via one turso::Database factory handing each
  wire session its own turso::Connection (busy timeout 5000ms default).
- Busy errors tagged with SQLite phrasing so the mysql/postgres error_map
  classifiers produce retryable lock-wait codes.
- VACUUM rejected with a clear unsupported error; multi-process access,
  ATTACH/DETACH, and non-UTF-8 TEXT caveats documented in crate docs.
- Facade: feature "turso", off by default; re-exports litewire_turso and
  Turso.
- Tests mirror the rusqlite backend suite (17 unit tests incl. isolation)
  plus a litewire-level integration test (sessions, transactions,
  last_insert_rowid, affected rows, describe_columns).
Self-contained runner for the ePHPm Turso-engine roadmap decision gates:
- bench: point SELECT / INSERT / 10-query page p50-p99, turso vs rusqlite
- writers: N concurrent BackendConns inserting (MVCC vs WAL+busy_timeout),
  throughput + busy/error counts
- gate3: SQLite<->Turso file-format round-trip with checksums and
  integrity_check in both directions
- crash: SIGKILL a turso-engine writer child mid-loop, reopen, verify with
  both engines (N iterations)

Also: litewire-backend becomes a default-features=false path dep at
runtime (the trait is all the crate needs); rusqlite is dev-only for the
comparison harness.
@luthermonson
luthermonson merged commit 0ff501e into main Jul 15, 2026
3 checks passed
@luthermonson
luthermonson deleted the feat/turso-backend branch July 15, 2026 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant