feat: experimental Turso Database engine backend (litewire-turso) - #9
Merged
Conversation
…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.
…-backend parity; engine default is FULL)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 1 of the ePHPm Turso-engine roadmap: an experimental backend implementing
Backend/BackendConnover Turso Database, the Rust rewrite of SQLite.crates/litewire-turso, engine pinned exactly atturso = "=0.7.0"(first non-pre release of the 0.7 line; Beta upstream — bump deliberately, never viacargo update).turso, off by default; re-exportslitewire_tursoandTurso.spawn_blockinghop); per-sessiontokio::sync::Mutexmirrors the rusqlite backend's session semantics. Oneturso::Databasefactory, oneturso::Connectionper wire session (per-conn transaction isolation).busy_timeout5000 ms andPRAGMA synchronous = NORMAL(the engine's own default isFULL— a 40x concurrent-write throughput difference, see the harness).error_mapclassifiers emit retryable lock-wait codes.VACUUM(rejected with a clear error), multi-process access,ATTACH/DETACH, non-UTF-8TEXTround-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'sdocs/turso-phase1-results.md(companion PR).Consumed by ephpm's
feat/db-engine-turso-experimentalbranch (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 testscargo test --workspacegreencargo clippy --workspace --all-targets -- -D warningsgreen (turso feature checked separately:cargo check -p litewire --features turso)